PR 53645: Fix menu to not lose state on page transitions
- Move hamburger and menu from per page to MainPage, allowing it's state to
This commit is contained in:
Коммит
c516bf3803
|
@ -10,6 +10,18 @@
|
|||
Loaded="Page_Loaded"
|
||||
>
|
||||
|
||||
<Frame x:Name="MainFrame" ></Frame>
|
||||
<Grid x:Name="RootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
|
||||
<Frame x:Name="MainFrame" Navigated="MainFrame_Navigated"/>
|
||||
|
||||
<StackPanel Grid.Column="0">
|
||||
<Button Style="{StaticResource SplitViewTogglePaneButtonStyle}"
|
||||
Click="ShowSplitView"/>
|
||||
<Button Style="{StaticResource SplitViewTogglePaneButtonStyle}" Content=""
|
||||
x:Name="HomeButton" Click="NavigateHome"/>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
<local:SampleListControl x:Name="MySampleListControl"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -135,10 +135,35 @@ namespace CompositionSampleGallery
|
|||
|
||||
private void Page_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MySampleListControl.NavigationFrame = MainFrame;
|
||||
|
||||
MainFrame.Navigate(typeof(HomePage));
|
||||
|
||||
// Now that loading is complete, dismiss the custom splash screen
|
||||
HideCustomSplashScreen();
|
||||
}
|
||||
|
||||
private void ShowSplitView(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MySampleListControl.SamplesSplitView.IsPaneOpen = !MySampleListControl.SamplesSplitView.IsPaneOpen;
|
||||
}
|
||||
|
||||
private void NavigateHome(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainFrame.Navigate(typeof(HomePage));
|
||||
HomeButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void MainFrame_Navigated(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
if (e.SourcePageType == typeof(HomePage))
|
||||
{
|
||||
HomeButton.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
HomeButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ namespace CompositionSampleGallery
|
|||
_textSprite.StartAnimation("Offset", offsetAnimation);
|
||||
}
|
||||
|
||||
private async void CreateImageAndLights(Vector2 sizeLightBounds)
|
||||
private void CreateImageAndLights(Vector2 sizeLightBounds)
|
||||
{
|
||||
//
|
||||
// Image and effect setup
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid x:Name="RootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid x:Name="RootGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Padding="15,5,15,5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
|
@ -19,14 +19,12 @@
|
|||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Style="{StaticResource SplitViewTogglePaneButtonStyle}"
|
||||
Click="ShowSplitView"/>
|
||||
|
||||
<StackPanel Orientation="Vertical" Grid.Column="1" Grid.Row="0">
|
||||
<TextBlock Text="Windows UI Dev Labs"
|
||||
VerticalAlignment="Center"
|
||||
Style="{ThemeResource TitleTextBlockStyle}"
|
||||
Margin="0,0,0,10"
|
||||
Padding="45,0,0,0"
|
||||
FontWeight="Bold"
|
||||
FontSize="24"
|
||||
Grid.Column="1"/>
|
||||
|
@ -82,9 +80,6 @@
|
|||
<LineBreak/> Copyright (c) Microsoft Corporation. All rights
|
||||
</Paragraph>
|
||||
</RichTextBlock>
|
||||
|
||||
|
||||
<local:SampleListControl x:Name="MySampleListControl" Grid.ColumnSpan="2" Grid.RowSpan="3" />
|
||||
</Grid>
|
||||
|
||||
</Page>
|
||||
|
|
|
@ -67,11 +67,6 @@ namespace CompositionSampleGallery
|
|||
FeaturedSampleList.ItemsSource = featuredSamples;
|
||||
}
|
||||
|
||||
private void ShowSplitView(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MySampleListControl.SamplesSplitView.IsPaneOpen = !MySampleListControl.SamplesSplitView.IsPaneOpen;
|
||||
}
|
||||
|
||||
private void FeaturedSampleList_ItemClick(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
FeaturedSample sample = (FeaturedSample)e.ClickedItem;
|
||||
|
|
|
@ -18,14 +18,7 @@
|
|||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="0">
|
||||
<Button Style="{StaticResource SplitViewTogglePaneButtonStyle}"
|
||||
Click="ShowSplitView"/>
|
||||
<Button Style="{StaticResource SplitViewTogglePaneButtonStyle}" Content=""
|
||||
Click="NavigateHome"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Grid.Column="1" Margin="5">
|
||||
<StackPanel Grid.Column="1" Padding="50,5,5,5">
|
||||
<TextBlock
|
||||
x:Name="SampleName"
|
||||
x:FieldModifier="public"
|
||||
|
@ -45,9 +38,7 @@
|
|||
Content="Click here to see the sample code on GitHub"
|
||||
Margin="5,5,5,5"/>
|
||||
</StackPanel>
|
||||
|
||||
<Frame x:Name="ContentFrame" x:FieldModifier="Public" Grid.Row="1" Grid.ColumnSpan="2"/>
|
||||
|
||||
<local:SampleListControl x:Name="MySampleListControl" Grid.ColumnSpan="2" Grid.RowSpan="2"/>
|
||||
<Frame x:Name="ContentFrame" x:FieldModifier="Public" Grid.Row="1" Grid.ColumnSpan="2"/>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -35,15 +35,5 @@ namespace CompositionSampleGallery
|
|||
SampleDefinition definition = (SampleDefinition)e.Parameter;
|
||||
ContentFrame.Navigate(definition.Type, this);
|
||||
}
|
||||
|
||||
private void ShowSplitView(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MySampleListControl.SamplesSplitView.IsPaneOpen = !MySampleListControl.SamplesSplitView.IsPaneOpen;
|
||||
}
|
||||
|
||||
private void NavigateHome(object sender, RoutedEventArgs e)
|
||||
{
|
||||
((Frame)Window.Current.Content).Navigate(typeof(HomePage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,14 @@ namespace CompositionSampleGallery
|
|||
SampleViewSource.Source = result;
|
||||
}
|
||||
|
||||
public Frame NavigationFrame { get; internal set; }
|
||||
|
||||
private void SampleList_ItemClick(object sender, ItemClickEventArgs e)
|
||||
{
|
||||
SampleDefinition definition = e.ClickedItem as SampleDefinition;
|
||||
((Frame)Window.Current.Content).Navigate(typeof(SampleHost), definition);
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
NavigationFrame.Navigate(typeof(SampleHost), definition);
|
||||
|
||||
SamplesSplitView.IsPaneOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче