简体   繁体   English

云母材料未出现在辅助 window 上

[英]Mica material not showing up on secondary window

I have a little problem with a multi-window UWP app.我对多窗口 UWP 应用程序有一点问题。

I have the Mica material applied to my page and when I run my program, the first window shows with the Mica material.我将云母材料应用于我的页面,当我运行我的程序时,第一个 window 显示为云母材料。 If I click on show second window, It pops up, but the background is in my system-accent-color, not the Mica material.如果我点击显示第二个 window,它会弹出,但背景是我的系统强调色,而不是云母材料。

Here my code of MainPage.xaml:这是我的 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:主页.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();
}

Here is also an image, as you can see the first window has the Mica material and the second one is only colored in my Accent color:这也是一张图片,您可以看到第一个 window 具有云母材料,第二个仅以我的口音颜色着色: 在此处输入图像描述

Can someone explain this phenomenon?有人可以解释这种现象吗? Or did I do something wrong?还是我做错了什么? Or is it a bug from Microsoft?还是微软的错误?

Mica material not showing up on secondary window云母材料未出现在辅助 window 上

It looks BackdropMaterial is not compatible with AppWindow , please go ahead post this in WinUI github, and currently there is a workaround that use ApplicationView to implement multiple views.看起来BackdropMaterialAppWindow不兼容,请 go 提前在 WinUI github 中发布此内容,目前有一种解决方法,使用ApplicationView来实现多个视图。 And ApplicationView could show BackdropMaterial correctly in the second view.并且 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);

For more detail, please refer to document here .更多详细信息,请参阅此处的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM