我對多視窗 UWP 應用程式有一點問題。
我將云母材料應用到我的頁面,當我運行我的程式時,第一個視窗顯示云母材料。如果我點擊顯示第二個視窗,它會彈出,但背景是我的系統強調色,而不是云母材料。
這是我的 MainPage.xaml 代碼:
<Page
x:Class="MultiWindowTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MultiWindowTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
muxc:BackdropMaterial.ApplyToRootOrPageBackground="True">
<Grid>
<Button Click="Button_Click" Content="New Window" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Page>
MainPage.xaml.cs:
private async void Button_Click(object sender, RoutedEventArgs e)
{
AppWindow appWindow = await AppWindow.TryCreateAsync();
Frame appWindowContentFrame = new Frame();
appWindowContentFrame.Navigate(typeof(MainPage));
ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowContentFrame);
await appWindow.TryShowAsync();
}
這也是一張圖片,你可以看到第一個視窗有云母材料,第二個視窗只用我的口音顏色著色:

有人可以解釋這種現象嗎?還是我做錯了什么?還是微軟的錯誤?
uj5u.com熱心網友回復:
云母材料未顯示在輔助視窗上
看起來BackdropMaterial與 不兼容AppWindow,請繼續在 WinUI github 中發布此內容,目前有一種解決方法可用于ApplicationView實作多個視圖。并且 ApplicationView 可以BackdropMaterial在第二個視圖中正確顯示。
CoreApplicationView newView = CoreApplication.CreateNewView();
int newViewId = 0;
await newView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
Frame frame = new Frame();
frame.Navigate(typeof(MainPage), null);
Window.Current.Content = frame;
// You have to activate the window in order to show it later.
Window.Current.Activate();
newViewId = ApplicationView.GetForCurrentView().Id;
});
bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(newViewId);
更多詳細資訊,請參閱此處的檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/404807.html
標籤:
下一篇:聚焦時為條目設定邊框顏色
