標籤:
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編程學習點滴二——裝置方向、系統主題和系統托盤