积极答复者
通过WindowSizeChanged 切换 全屏 和 侧边栏 该怎么写 C++

问题
答案
-
注意的你VisualStateManager.VisualStateGroups的位置,
如下是针对你位置的修改。
<common:LayoutAwarePage x:Name="pageRoot" x:Class="TESTWin8.DetailsPage" DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:TESTWin8" xmlns:common="using:TESTWin8.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Loaded="PageLoadedHandler"> <Page.Resources> <!-- TODO: Delete this line if the key AppName is declared in App.xaml --> <x:String x:Key="AppName">详情页</x:String> </Page.Resources> <ScrollViewer Style="{StaticResource HorizontalScrollViewerStyle}" HorizontalScrollBarVisibility="Auto"> <Grid Style="{StaticResource LayoutRootStyle}" Background="#C5C5C5"> <Grid x:Name="first">//第一个 <TextBlock Text="big" FontSize="48" Foreground="Red" /> </Grid> <Grid x:Name="second" Visibility="Collapsed" > //第二个 <TextBlock Text="small" FontSize="48" Foreground="Red"/> </Grid> </Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState x:Name="FullScreenLandscape"/> <VisualState x:Name="Filled"/> <VisualState x:Name="FullScreenPortrait"/> <VisualState x:Name="Snapped"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="first" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="second" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </ScrollViewer> </common:LayoutAwarePage>
Thanks! Damon.Tian
- 已标记为答案 英明神武可爱 2012年9月6日 12:09
全部回复
-
我看到你继承了LayoutAwarePage,可以直接在Xaml中加入如下代码,控制你的2个Grid切换,注意替换你的Grid的name
<VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState x:Name="FullScreenLandscape"/> <VisualState x:Name="Filled"/> <VisualState x:Name="FullScreenPortrait"/> <VisualState x:Name="Snapped"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LandscapeGrid" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnappedGrid" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups>
Thanks! Damon.Tian
-
<common:LayoutAwarePage x:Name="pageRoot" x:Class="TESTWin8.DetailsPage" DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:TESTWin8" xmlns:common="using:TESTWin8.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Loaded="PageLoadedHandler"> <Page.Resources> <!-- TODO: Delete this line if the key AppName is declared in App.xaml --> <x:String x:Key="AppName">详情页</x:String> </Page.Resources> <ScrollViewer Style="{StaticResource HorizontalScrollViewerStyle}" HorizontalScrollBarVisibility="Auto"> <Grid Style="{StaticResource LayoutRootStyle}" Background="#C5C5C5"> <Grid x:Name="first">//第一个 <TextBlock Text="big" FontSize="48" Foreground="Red" /> </Grid> <Grid x:Name="second" Visibility="Collapsed" > //第二个 <TextBlock Text="small" FontSize="48" Foreground="Red"/> </Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState x:Name="FullScreenLandscape"/> <VisualState x:Name="Filled"/> <VisualState x:Name="FullScreenPortrait"/> <VisualState x:Name="Snapped"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="first" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="second" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Grid> </ScrollViewer> </common:LayoutAwarePage>
我按你说的,试试没有效果。
-
注意的你VisualStateManager.VisualStateGroups的位置,
如下是针对你位置的修改。
<common:LayoutAwarePage x:Name="pageRoot" x:Class="TESTWin8.DetailsPage" DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}" IsTabStop="false" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:TESTWin8" xmlns:common="using:TESTWin8.Common" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Loaded="PageLoadedHandler"> <Page.Resources> <!-- TODO: Delete this line if the key AppName is declared in App.xaml --> <x:String x:Key="AppName">详情页</x:String> </Page.Resources> <ScrollViewer Style="{StaticResource HorizontalScrollViewerStyle}" HorizontalScrollBarVisibility="Auto"> <Grid Style="{StaticResource LayoutRootStyle}" Background="#C5C5C5"> <Grid x:Name="first">//第一个 <TextBlock Text="big" FontSize="48" Foreground="Red" /> </Grid> <Grid x:Name="second" Visibility="Collapsed" > //第二个 <TextBlock Text="small" FontSize="48" Foreground="Red"/> </Grid> </Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup> <VisualState x:Name="FullScreenLandscape"/> <VisualState x:Name="Filled"/> <VisualState x:Name="FullScreenPortrait"/> <VisualState x:Name="Snapped"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="first" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/> </ObjectAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="second" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </ScrollViewer> </common:LayoutAwarePage>
Thanks! Damon.Tian
- 已标记为答案 英明神武可爱 2012年9月6日 12:09