首页 > 其他 > 详细

D24_01_基于页面的界面(page)

时间:2014-11-02 16:23:58      阅读:161      评论:0      收藏:0      [点我收藏+]

bubuko.com,布布扣

 

<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)

原文:http://www.cnblogs.com/xiepengtest/p/4069293.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!