sameer
sameer

Reputation: 342

How to Open multiple window using AppWindow in xamarin forms UWP?

As i have using 'AppWindow' to open separate window in xamarin forms UWP. I tried below code to open the window,

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

When 'Appwindow.TryCreateAsync' method calling, it will be thrown 'Class not registered exception'. Please see the below snippet,

enter image description here

I tried to check about this issue and also trying to find a solution. But i am not getting any solution to fix this. Please let me know, if you have faced same this issue or any solution to fix it.

Upvotes: 0

Views: 498

Answers (1)

Leon Lu
Leon Lu

Reputation: 9244

Please make sure your testpage extend Page.

I create a blank page called AppWindowMainPage like following screenshot.

enter image description here

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>

When I run the code, it could open a new window.

enter image description here

Upvotes: 1

Related Questions