码迷,mamicode.com
首页 > 其他好文 > 详细

D24_01_基于页面的界面(page)

时间:2014-11-02 16:25:53      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   for   sp   

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)

标签:style   blog   http   io   color   ar   os   for   sp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!