zoukankan      html  css  js  c++  java
  • WPF 体验导航窗口

    导航窗口是指带有导航工具的窗口。典型的win7窗体。

    WPF 的导航窗体常见的有两种:Frame和NavigationWindow。

    先看NavigationWindow:创建一个WPF Project,再添加一个Page.xaml。因为导航的内容大都基于Page的。

    代码
    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Windows;
    using System.Windows.Navigation;

    namespace WpfProject
    {
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
    protected override void OnStartup(StartupEventArgs e)
    {
    base.OnStartup(e);
    NavigationWindow nw
    = new NavigationWindow();
    nw.Content
    = new NovaGation.MainPage1();
    nw.Show();
    }
    }
    }

    引用System.Windows.Navigation,创建对象,或者可以修改Window节点为NavigationWindow。

    Frame,frame可以看作一个ContentControl,他的Content是一个Page。

    代码
    <Window x:Class="WpfProject.NovaGation.FrameNova"
    xmlns
    ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x
    ="http://schemas.microsoft.com/winfx/2006/xaml"
    Title
    ="FrameNova" Height="300" Width="300">
    <StackPanel>
    <TextBlock Background="BurlyWood" FontSize="15" FontWeight="25" Height="30" VerticalAlignment="Center">
    <Hyperlink x:Name="homeHyper" Click="homeHyper_Click">Back to MainPage</Hyperlink>
    </TextBlock>
    <Frame Name="Frame1" Background="AliceBlue" Source="NaviPage2.xamll" NavigationUIVisibility="Visible" />
    </StackPanel>
    </Window>
    代码
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Shapes;

    namespace WpfProject.NovaGation
    {
    /// <summary>
    /// Interaction logic for FrameNova.xaml
    /// </summary>
    public partial class FrameNova : Window
    {
    public FrameNova()
    {
    InitializeComponent();
    }

    private void homeHyper_Click(object sender, RoutedEventArgs e)
    {
    this.Frame1.Navigate(new Uri("NovaGation\\MainPage1.xaml", UriKind.Relative));
    }
    }
    }

  • 相关阅读:
    windows bat脚本检测空白文件
    linux把文件夹作为img镜像给rk3288烧录
    嵌入式非浮点型交叉编译器下载
    嵌入式linux date -s写入保存时间后,开机启动相差八小时
    android5.1编译 collect2: ld terminated with signal 9 [Killed]
    qt5.9.9交叉编译并运行到目标板完整版(无界面版本)
    嵌入式linux编译移植 vsftpd 源码修改
    嵌入式Linux板子date时间和hwclock不一致
    ubuntu14.0输入密码后进不去桌面
    C 语言 指针
  • 原文地址:https://www.cnblogs.com/jimson/p/WPF3.html
Copyright © 2011-2022 走看看