zoukankan      html  css  js  c++  java
  • 让你知道手机为什么转动时屏幕会转变(页面的显示切换)Windows Phone 7 平台 X

    打开windows phone 7的开发环境,新建一个project修改主页面的标题和application name,由于暂时无法支持中文,所以都用英语命名,在Mainpage.xaml的页面上新建3个按钮,分别命名为 PortraitPage、LandscapePage、NeutralPage 然后双击button添加Click事件,每个按钮的事件的代码如下:

    private void onPortraitPage(object sender, RoutedEventArgs e)
    {
    NavigationService.Navigate(
    new Uri("/PortraitPage.xaml", UriKind.Relative));
    }

    private void onLandscapePage(object sender, RoutedEventArgs e)
    {
    NavigationService.Navigate(
    new Uri("/LandscapePage.xaml", UriKind.Relative));
    }

    private void onNeutralPage(object sender, RoutedEventArgs e)
    {
    NavigationService.Navigate(
    new Uri("/NeutralPage.xaml", UriKind.Relative));
    }

    上面代码中显示了三个xaml,所以我们要插入三个xaml 页面名字为ProtraitPage.xaml、 LandscapePage.xaml(注意插入该xaml时选第一个页面类型就是横屏显示的)、NeutralPage.xaml;

    这下在对ProtraitPage.xaml和NeutralPage.xaml进行编码:

    在ProtraitPage.xaml中的public Page1()中的   InitializeComponent();下插入一行

    SupportedOrientations = SupportedPageOrientation.Portrait;

    NeutralPage.xaml:

    public Page3()中的   InitializeComponent();下插入一行

        SupportedOrientations = SupportedPageOrientation.PortraitOrLandscape;
    现在就可以运行了可以看到:
    点Protrait按钮出现的页面还是竖立的;  点Landscape页面变成横的啦; 点Neutral时,手机竖立时页面显示就是竖立的,而如果手机横过来,页面就横过来了;
    --这就是一些手机为什么横过来和竖过来页面会跟着变换
    效果图:

  • 相关阅读:
    汇编中push寄存器的影响
    windows lsp 指导
    java匹配中文汉字的正则表达式
    php中preg_match用户名正则实例
    Javascript中while和do-while循环用法详解
    如何找出MySQL数据库中的低效SQL语句
    asp.net连接oracle的问题及方法总结
    asp.net运算符之逻辑运算符以及其他运算符
    用命令行将Java程序打包为jar文件
    php 中cookie和session的用法比较
  • 原文地址:https://www.cnblogs.com/xspaceworld/p/1776988.html
Copyright © 2011-2022 走看看