I'm having a problem related to handle events. I had MainPage which contained a SplitView. It might be a base page. There were 2 buttons used to navigate frame in SplitView.Contant. A button is used to navigate to HomePage. The other is used to navigate to a page that contains a form to fill some fields. the page's name is AddSomething. I want to back to my home page immediately after clicking on button "Save".
MainPage XAML:
<SplitView x:Name="MainMenu" DisplayMode="Overlay">
<SplitView.Pane>
<Grid>
<StackPanel>
<Button x:Name="BtHome"
HorizontalAlignment="Stretch"
Content="Home"/>
<Button x:Name="BtAddSth"
HorizontalAlignment="Stretch"
Content="Add Something"/>
</StackPanel>
</Grid>
</SplitView.Pane>
<SplitView.Content>
<Frame x:Name="NavigatedFrame"/> <-! That's used to navigate -->
</SplitView.Content>
</SplitView>`
AddSomthingPage XAML:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel VerticalAlignment="Center">
<TextBox x:Name="Name" PlaceholderText="Name"/>
<TextBox x:Name="Place" PlaceholderText="Place"/>
<Grid HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="BtSaveToDB"
Grid.Column="0"
Content="Save"/>
<Button x:Name="BtReset"
Grid.Column="1"
Content="Reset"/>
</Grid>
</StackPanel>
</Grid>
When I click on button "Save", I can go back to the home page. I don't want any change in my xaml. Especially I don't want to load MainPage anymore. Thanks in advance.
When you click save
// this will tell NavigatedFrame to go
// back to previous page, assume that you set it to navigate to MainPage first
NavigatedFrame.GoBack()
In MainPage.xaml, add this line to thet Page node
NavigationCacheMode="Required"
It will cache the mainpage and prevent it from loading again.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.