zoukankan      html  css  js  c++  java
  • windows phone 7 基本导航

    一个简单的示例------页面间导航。

      在MainPage.xaml的内容区域(content area)放置一个TextBlock,并对其ManipulationStarted事件注册一个事件处理程序:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margain="12,0,12,0">

      <TextBlock Text="导航到第二个页面"  //TextBlock要显示的文本信息

            HorizontalAlignment="Center"  //水平对齐方式为居中

            VerticalAlingment="Center"   //竖直对齐方式为居中

            Padding="0 34"  //内边距设置

            ManipulationStarted="OnTextBlockManipulationStarted" />

    </Grid>

        在MainPage.xaml.cs中的构造函数后面添加以下代码

      void OnTextBlockManipulationStarted(object sender,ManipulationStartedEventArgs e)

    {

      //Navigate方法的第一个参数是一个Uri类型的对象。第二个参数使用了UriKind.Relative来标明此Uri是相对于MainPage.xaml文件的相对位置。

      this.NavigationService.Navigate(new Uri("/SecondPage.xaml",UriKind.Relative));

      

      e.Complete();

      e.Handled = true;

    }

      代码到此已ok,接下来创建第二个页面

      在Visual Studio的SolutionExplorer上右击项目名,选择Add(新增)和New Item(新建项),选择 Windows Phone Portrait Page(Windows Phone竖直页面),改名为SecondPage

      SecondPage的内容,和第一个页面类似

    <Grid x:Name="ContentPanel" Grid.Row="1" Margain="12,0,12,0">

      <TextBlock Text="返回到第一个页面"  

            HorizontalAlignment="Center" 

            VerticalAlingment="Center"  

            Padding="0 34"  

            ManipulationStarted="OnTextBlockManipulationStarted" />

    </Grid>

      接下来在SecondPage.xaml.cs里创建返回第一个页面的触摸事件

      void OnTextBlockManipulationStarted(object sender,ManipulationStartedEventArgs e)

    {

      this.NavigateService.GoBack();

      e.Complete();

      e.Handled = true;

    }

      提示:要先引入System.Windows.Navigation命名空间

  • 相关阅读:
    android api 中文 (74)—— AdapterView.AdapterContextMenuInfo
    Android API 中文(76)——AdapterView.OnItemLongClickListener
    Android 中文api (81)——InputMethod [输入法]
    android 中文 api (87) —— BaseInputConnection
    Android 中文API合集(4)(102篇)(chm格式)
    Android中文API(97)—— ContextMenu
    android api 中文 (75)—— AdapterView.OnItemClickListener
    android 中文api (84) —— TrafficStats
    Windows XP 上安装 Bind9
    数据库索引实例之三
  • 原文地址:https://www.cnblogs.com/sparks/p/2517288.html
Copyright © 2011-2022 走看看