UWP应用程序 - 背景图像在导航上迷路
问题描述:
我正在开发UWP应用程序,并且在导航到不同页面时遇到了背景图像更改的问题。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})。
如果您希望页面是透明的,以便用户能够看到根网格的背景图像,您可以在页面的根元素上设置Background =“Transparent”。
希望这有助于 - 谢谢!
Stefan Wick
昨天晚上注意到了这一点,忘记了更新。你是对的!新页面默认将背景设置为“ApplicationPageBackgroundThemeBrush”。 –