Reputation: 342
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,
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
Reputation: 9244
Please make sure your testpage
extend Page
.
I create a blank page called AppWindowMainPage
like following screenshot.
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.
Upvotes: 1