mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Navigate with RootFrame instead
This commit is contained in:
parent
3ff418f096
commit
0873be2f6b
5 changed files with 22 additions and 35 deletions
|
@ -20,34 +20,41 @@
|
|||
<ScrollViewer>
|
||||
<Grid x:Name="PageGrid" AutomationProperties.LandmarkType="Main">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="1*"
|
||||
MinHeight="{StaticResource HamburgerHeight}"
|
||||
MaxHeight="52"/>
|
||||
<RowDefinition Height="1*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<local:TitleBar/>
|
||||
</Grid>
|
||||
|
||||
<Grid Height="{StaticResource HamburgerHeight}"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top">
|
||||
VerticalAlignment="Top"
|
||||
Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="{StaticResource HamburgerHeightGridLength}"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button x:Name="BackButton"
|
||||
x:Uid="BackButton"
|
||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||
Click="BackButtonClick"/>
|
||||
x:Uid="BackButton"
|
||||
Style="{StaticResource NavigationBackButtonNormalStyle}"
|
||||
Grid.Row="1"
|
||||
Click="BackButtonClick"/>
|
||||
|
||||
<TextBlock x:Uid="SettingsHeader"
|
||||
Grid.Column="1"
|
||||
Margin="8,-3,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource CategoryNameTextBlockStyle}"/>
|
||||
Grid.Column="1"
|
||||
Margin="8,-3,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource CategoryNameTextBlockStyle}"/>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="1" Margin="12,0,12,0">
|
||||
<StackPanel Grid.Row="2" Margin="12,0,12,0">
|
||||
<StackPanel x:Name="SettingsStack"
|
||||
AutomationProperties.LabeledBy="{Binding ElementName=SettingsAppTheme}"
|
||||
Orientation="Vertical">
|
||||
|
|
|
@ -95,15 +95,6 @@ SettingsPage::SettingsPage()
|
|||
}
|
||||
}
|
||||
|
||||
void SettingsPage::OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e)
|
||||
{
|
||||
MainPage ^ mainPage = dynamic_cast<MainPage ^> (e->Parameter);
|
||||
if (mainPage != nullptr)
|
||||
{
|
||||
MainPageProperty = mainPage;
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsPage::SetDefaultFocus()
|
||||
{
|
||||
SettingsLightTheme->Focus(::FocusState::Programmatic);
|
||||
|
@ -139,6 +130,8 @@ void SettingsPage::InitializeContributeTextBlock()
|
|||
|
||||
void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
auto rootFrame = dynamic_cast<::Frame ^>(Window::Current->Content);
|
||||
|
||||
if (SettingsRestartApp->Visibility == ::Visibility::Visible)
|
||||
{
|
||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"True");
|
||||
|
@ -147,7 +140,7 @@ void SettingsPage::BackButtonClick(Platform::Object ^ sender, Windows::UI::Xaml:
|
|||
{
|
||||
Windows::Storage::ApplicationData::Current->LocalSettings->Values->Insert(L"restartApp", L"False");
|
||||
}
|
||||
MainPageProperty->CollapseSettings();
|
||||
rootFrame->Navigate((MainPage::typeid), this);
|
||||
}
|
||||
|
||||
void SettingsPage::SetVersionString()
|
||||
|
|
|
@ -15,9 +15,6 @@ namespace CalculatorApp
|
|||
SettingsPage();
|
||||
property MainPage ^ MainPageProperty;
|
||||
|
||||
protected:
|
||||
virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
void SetDefaultFocus();
|
||||
void InitializeContributeTextBlock();
|
||||
|
|
|
@ -383,10 +383,8 @@ void MainPage::EnsureConverter()
|
|||
|
||||
void MainPage::EnsureSettings()
|
||||
{
|
||||
SettingsHolder->Navigate((SettingsPage::typeid), this);
|
||||
SettingsHolder->Visibility = ::Visibility::Visible;
|
||||
NavView->IsPaneOpen = false;
|
||||
NavView->Visibility = ::Visibility::Collapsed;
|
||||
auto rootFrame = dynamic_cast<::Frame ^>(Window::Current->Content);
|
||||
rootFrame->Navigate((SettingsPage::typeid), this);
|
||||
}
|
||||
|
||||
void MainPage::OnNavLoaded(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
|
@ -449,12 +447,6 @@ void MainPage::OnSettingsButtonKeyDown(Object ^ sender, KeyRoutedEventArgs ^ e)
|
|||
}
|
||||
}
|
||||
|
||||
void MainPage::CollapseSettings()
|
||||
{
|
||||
SettingsHolder->Visibility = ::Visibility::Collapsed;
|
||||
NavView->Visibility = ::Visibility::Visible;
|
||||
}
|
||||
|
||||
void MainPage::OnNavSelectionChanged(_In_ Object ^ sender, _In_ MUXC::NavigationViewSelectionChangedEventArgs ^ e)
|
||||
{
|
||||
auto item = dynamic_cast<MUXC::NavigationViewItem ^>(e->SelectedItemContainer);
|
||||
|
|
|
@ -39,8 +39,6 @@ public
|
|||
Platform::Object
|
||||
^> ^ CreateUIElementsForCategories(_In_ Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup ^> ^ categories);
|
||||
|
||||
void CollapseSettings();
|
||||
|
||||
protected:
|
||||
void OnNavigatedTo(_In_ Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue