Windows Phone 7编程学习点滴二——设备方向系统主题和系统托盘
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Windows Phone 7编程学习点滴二——设备方向系统主题和系统托盘相关的知识,希望对你有一定的参考价值。
1 有两种方式可以改变设备的方向:
(1) 将SupportedOrientation设置为“PortraitOrLandscape”让操作系统为你实现。
(2) 是通过代码实现: OrientationChanged 事件。
1 this.OrientationChanged += new EventHandler<OrientationChangedEventArgs>(MainPage_OrientationChanged);
1 void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e) 2 { 3 if ((e.Orientation == PageOrientation.LandscapeRight) || (e.Orientation == PageOrientation.LandscapeLeft)) 4 { 5 TitlePanel.Visibility = Visibility.Collapsed; 6 } 7 else if ((e.Orientation == PageOrientation.PortraitDown) || (e.Orientation == PageOrientation.PortraitUp)) 8 { 9 TitlePanel.Visibility = Visibility.Visible; 10 } 11 } 12 }
2 系统主题
在Visual Studio中右击此项目,选择“Open In Expression Blend…” 或在View菜单中选择“Open In Expression Blend…”。
在Blend的UI中有一个标签叫“Device”,看起来像这样:
<Grid x:Name="LayoutRoot" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> <!--TitlePanel contains the name of the application and page title--> <Rectangle Stroke="Black" Grid.RowSpan="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="{StaticResource PhoneBackgroundColor}" Offset="0"/> <GradientStop Color="{StaticResource PhoneAccentColor}" Offset="1"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <!--TitlePanel contains the name of the application and page title--> <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> <TextBlock x:Name="ApplicationTitle" Text="BLANKENSOFT" Style="{StaticResource PhoneTextNormalStyle}" mce_Style="{StaticResource PhoneTextNormalStyle}"/> <TextBlock x:Name="PageTitle" Text="system theming" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}" mce_Style="{StaticResource PhoneTextTitle1Style}"> <TextBlock.Foreground> <SolidColorBrush Color="{StaticResource PhoneAccentColor}"/> </TextBlock.Foreground> </TextBlock> </StackPanel> <!--ContentPanel - place additional content here--> <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <TextBlock Height="601" TextWrapping="Wrap" HorizontalAlignment="Left" Margin="0,6,0,0" x:Name="textBlock1" Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mollis turpis sit amet diam elementum molestie. Cras quis massa ante. Morbi sit amet arcu quam, non dignissim nibh. Nunc lectus leo, ornare quis imperdiet id, fringilla vel diam. Proin vitae augue non sem sollicitudin imperdiet ut quis diam. Nulla vitae nulla eros. Curabitur mauris justo, eleifend eu sodales ac, blandit vitae mauris. Pellentesque erat lorem, euismod at sodales eget, sollicitudin sed velit. Praesent est sapien, hendrerit tempor tincidunt quis, posuere ac nunc. Nam odio nisl, feugiat eget blandit sit amet, dapibus id tellus. Sed blandit nisi nunc. Aliquam fermentum justo tristique risus porta sollicitudin. Aenean aliquam congue ornare. Curabitur blandit mi quis odio convallis adipiscing." VerticalAlignment="Top" Width="468" /> </Grid> </Grid>
3 系统托盘
shell:SystemTray.IsVisible
以上是关于Windows Phone 7编程学习点滴二——设备方向系统主题和系统托盘的主要内容,如果未能解决你的问题,请参考以下文章
以编程方式启用Windows Phone 7应用程序中的禁用复选框
使用 WCF 将 SQL Azure 连接到 Windows Phone 7