这是我的 MainPage.xaml
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:BibleApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Domain="using:BibleApp.Domain"
x:Class="BibleApp.MainPage">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<RelativePanel>
<Button Name="HamburgerButton"
FontFamily="Segoe MDL2 Assets"
Content="" FontSize="14"
Click="HamburgerButton_Click"/>
</RelativePanel>
<SplitView Name="MySplitView"
Grid.Row="1"
DisplayMode="CompactOverlay"
OpenPaneLength="200"
CompactPaneLength="34"
HorizontalAlignment="Left">
<SplitView.Pane>
<ListBox Name="IconsListBox" SelectionMode="Single" SelectionChanged="IconsListBox_SelectionChanged">
<ListBoxItem Name="Biblia">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="18"/>
<TextBlock Text="Bíblia" FontSize="12" Margin="15,0,0,0"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="PesquisarPalavraChave">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="18"/>
<TextBlock Text="Pesquisar palavra chave" FontSize="12" Margin="15,0,0,0"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem Name="PesquisarAssunto">
<StackPanel Orientation="Horizontal">
<TextBlock FontFamily="Segoe MDL2 Assets" Text="" FontSize="18"/>
<TextBlock Text="Pesquisar assunto" FontSize="12" Margin="15,0,0,0"/>
</StackPanel>
</ListBoxItem>
</ListBox>
</SplitView.Pane>
<SplitView.Content>
<Frame Name="MyFrame"/>
</SplitView.Content>
</SplitView>
</Grid>
</Page>
这是MainPage背后的代码:
private void IconsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
MyFrame = this.Frame;
if (Biblia.IsSelected) { Frame.Navigate(typeof(View.BiblePage), bible);}
else if (PesquisarPalavraChave.IsSelected) {Frame.Navigate(typeof(View.SearchWordPage));}
else if (PesquisarAssunto.IsSelected) { Frame.Navigate(typeof(View.SearchMatterPage)); }
}
这是 BiblePage OnNavigatedTo 事件:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
bible = (Bible)e.Parameter;
}
问题是没有触发 BiblePage 的“OnNavigatedTo”事件,因此我无法将“圣经”变量从 MainPage 传输到 BiblePage。
当我在拆分视图的内容之外执行此过程时,它可以完美运行。
如何在 MainPage 的 splitview 内容传递参数中加载 xaml 页面?