UWP 应用程序 - 背景图像在导航时丢失

UWP App - background image is getting lost on navigate

我正在开发一个 UWP 应用程序,当我导航到不同的页面时遇到背景图像发生变化的问题。

在我的 RootPage.xaml 文件中我有这个布局

 <Grid x:Name="Root">
    <Grid.Background>
        <ImageBrush 
            ImageSource="{Binding ImageSource}" 
            Stretch="UniformToFill" />
    </Grid.Background>
    <SplitView Name="Splitter" IsPaneOpen="False" DisplayMode="Overlay" PaneBackground="Transparent">
        <SplitView.Pane>
            <Grid>
                <!-- list view -->
            </Grid>
        </SplitView.Pane>
        <Frame Name="MainFrame"></Frame>
    </SplitView>
</Grid>

在我后面的代码中,我像这样处理选择更改事件中的更改

private void SectionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // code to get the navigation item page the event args
        // then navigate like so
        MainFrame.Navigate(item.DestinationPage);
    }

但是当我导航到其他页面之一时,我在网格上设置的背景图像丢失了。它只是变黑了。

我在这里遗漏了一些东西,我看了很多教程,但一定是遗漏了什么。我只想要框架所在的页面内容,并根据用户导航到的位置替换它。但是让拆分视图导航内容保留在每个页面上。

导航到 "DestinationPage" 后,您将看到在该页面的根元素上设置的任何背景(默认为:{ThemeResource ApplicationPageBackgroundThemeBrush})。

如果您希望页面透明,以便用户看到根 Grid 的背景图像,您可以在页面的根元素上设置 Background="Transparent"。

希望这对您有所帮助 - 谢谢!

斯蒂芬·维克