【问题标题】:How to Open multiple window using AppWindow in xamarin forms UWP?如何在 xamarin 表单 UWP 中使用 AppWindow 打开多个窗口?
【发布时间】:2021-06-20 03:03:52
【问题描述】:

正如我使用“AppWindow”在 xamarin 表单 UWP 中打开单独的窗口一样。我试过下面的代码打开窗口,

 if (appWindow == null)
        {
            appWindow = await AppWindow.TryCreateAsync();
            Frame appWindowFrame = new Frame();
            appWindowFrame.Navigate(typeof(testpage));
            ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame);
        }
        await appWindow.TryShowAsync();

'Appwindow.TryCreateAsync'方法调用时,会抛出'Class not registered exception'。请看下面的sn-p,

我尝试检查此问题并尝试找到解决方案。但我没有得到任何解决方案来解决这个问题。如果您遇到同样的问题或任何解决方案,请告诉我。

【问题讨论】:

    标签: xamarin uwp xamarin.uwp


    【解决方案1】:

    请确保您的testpage 扩展Page

    我创建了一个名为AppWindowMainPage 的空白页面,如下图所示。

    AppWindowMainPage.cs

      public sealed partial class AppWindowMainPage : Page
        {
            public AppWindowMainPage()
            {
                this.InitializeComponent();
            }
        }
    

    AppWindowMainPage.xaml

    <Page
        x:Class="App75.UWP.AppWindowMainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:App75.UWP"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d"
        Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    
        <Grid>
            <TextBlock Text="test"></TextBlock>
        </Grid>
    </Page>
    

    当我运行代码时,它会打开一个新窗口。

    【讨论】:

    • 嗨@Leon LU - MSFT,实际上,我在调用“await AppWindow.TryCreateAsync()”这个方法时遇到了异常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-09
    • 2018-05-18
    • 2016-01-04
    • 1970-01-01
    相关资源
    最近更新 更多