首页 > 代码库 > D24_01_基于页面的界面(page)

D24_01_基于页面的界面(page)

image

 

<Page x:Class="demo.Page1"      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"       xmlns:d="http://schemas.microsoft.com/expression/blend/2008"       WindowTitle="Page1">    <StackPanel Margin="3">        <!--导航到网页,如果导航失败,需要处理在APP.Xaml中处理事件NavigationFailed        <TextBlock Margin="3" TextWrapping="Wrap" >This is a simple page.            Click <Hyperlink NavigateUri="www.xiepeng.com">Here</Hyperlink> to go to Page2.</TextBlock>        -->        <!--#btn4表示导航到btn4元素,并不会让其获取焦点-->        <TextBlock Margin="3" TextWrapping="Wrap" >This is a simple page.            Click <Hyperlink NavigateUri="Page2.xaml#btn4">Here</Hyperlink> to go to Page2.</TextBlock>        <Button Margin="2" Padding="2">OK</Button>        <Button Margin="2" Padding="2">Close</Button>    </StackPanel></Page>

APP.xaml.cs()

using System;using System.Collections.Generic;using System.Configuration;using System.Data;using System.Linq;using System.Windows;namespace demo{    /// <summary>    /// App.xaml 的交互逻辑    /// </summary>    public partial class App : Application    {        //导航失败处理事件方法        private void Application_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)        {            if (e.Exception is System.Net.WebException)            {                MessageBox.Show("Website " + e.Uri.ToString() + " cannot be reached.");                e.Handled = true;            }        }    }}

D24_01_基于页面的界面(page)