首页 > 代码库 > D24_01_基于页面的界面(page)
D24_01_基于页面的界面(page)
<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)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。