WP7 开发 基础知识与问题积累

基础知识点:

1、获取WP7的DeviceUniqueId:

public string GetDeviceUniqueId()
{
  string strUniqueId = null;
  
object uniqueId = DeviceExtendedProperties.GetValue("DeviceUniqueId");   if (uniqueId != null)   {     byte[] uniqueBytes = (byte[]) uniqueId;     strUniqueId = Convert.ToBase64String(uniqueBytes);   }   return strUniqueId; }

 2、添加页面切换动画(需要使用到Microsoft.Phone.Controls.Toolkit):

修改App.xaml.cs文件:

private void InitializePhoneApplication()
{
  
if (phoneApplicationInitialized)
    
return;

  
// Create the frame but don't set it as RootVisual yet; this allows the splash
  
// screen to remain active until the application is ready to render.
  
// RootFrame = new PhoneApplicationFrame();
  RootFrame = new TransitionFrame();

  RootFrame.Navigated += CompleteInitializePhoneApplication;
  // Handle navigation failures
  
RootFrame.NavigationFailed += RootFrame_NavigationFailed;

  // Ensure we don't initialize again
  
phoneApplicationInitialized = true;
}

MainPage.xaml文件:

<phone:PhoneApplicationPage 
    x:Class="MyProject.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

  // 设置页面切换动画 <toolkit:TransitionService.NavigationInTransition> <toolkit:NavigationInTransition> <toolkit:NavigationInTransition.Backward> <toolkit:TurnstileTransition Mode="BackwardIn"/> </toolkit:NavigationInTransition.Backward> <toolkit:NavigationInTransition.Forward> <toolkit:TurnstileTransition Mode="ForwardIn"/> </toolkit:NavigationInTransition.Forward> </toolkit:NavigationInTransition> </toolkit:TransitionService.NavigationInTransition> <toolkit:TransitionService.NavigationOutTransition> <toolkit:NavigationOutTransition> <toolkit:NavigationOutTransition.Backward> <toolkit:TurnstileTransition Mode="BackwardOut"/> </toolkit:NavigationOutTransition.Backward> <toolkit:NavigationOutTransition.Forward> <toolkit:TurnstileTransition Mode="ForwardOut"/> </toolkit:NavigationOutTransition.Forward> </toolkit:NavigationOutTransition> </toolkit:TransitionService.NavigationOutTransition> <!--LayoutRoot is the root grid where all page content is placed--> <Grid x:Name="LayoutRoot" Background="Transparent">   </Grid> </phone:PhoneApplicationPage>

个人使用页面切换动画过程中遇到的问题:

1、页面A添加切换动画,页面B未添加切换动画;当A跳转到B时,在切换过程中点击“Back”键,程序会异常退出;

2、页面A与B都添加了切换动画,从A跳转到B,如果在B页面加载前点击“Back”键,会出现页面A、B重叠的现象。

 

遇到的问题:

1、Canvas中画PolyLine,当PolyLine的开始点与结束点距离过大时,该PolyLine无法显示。

XAML文件:

<Canvas>
  <Polyline x:Name="MyPolyLine" Canvas.Left="0" Canvas.Top="400" Stroke="Blue" StrokeThickness="6"/> </Canvas>

CS文件:

private void LoadLine()
{  
  PointCollection pointCollection
= new PointCollection();
  pointCollection.Add(
new Point(0, 0));
  pointCollection.Add(
new Point(200, 0));
  pointCollection.Add(
new Point(1000, 0));
  pointCollection.Add(
new Point(10000, 0));
  pointCollection.Add(
new Point(20000, 0));
  pointCollection.Add(
new Point(30000, 0));
  
  // 如果添加此点则PolyLine不显示
  // pointCollection.Add(new Point(40000, 0));

  this.MyPolyLine.Points = pointCollection; }

转载于:https://www.cnblogs.com/IronSword/archive/2012/04/13/2445844.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值