marb2000 / XamlIslands

Repository with several XAML Islands v1 samples (Win32, WPF, and WinForms) to demonstrate how to use it.
MIT License
47 stars 18 forks source link

SwapChainPanel example #9

Closed carmineos closed 5 years ago

carmineos commented 5 years ago

Hi could you please show an example about how to use a SwapChainPanel wrapped control in a .WPF .NET Core 3 app?

marb2000 commented 5 years ago

Hi @carmineos, you have a sample of SwapChainPanel in the WPF .NET Core 3 app.

This Grid contains the SwapChainPanel object in the UWP/WinRT XAML User Control: https://github.com/marb2000/XamlIslands/blob/362cdc62e3257156e3b19ce22210009844c71cc9/1903_Samples/Shared_Components/Managed_WinRT_Comp/Controls_Pages/MediaPage.xaml#L31

In the code behind you can find how I created it: https://github.com/marb2000/XamlIslands/blob/362cdc62e3257156e3b19ce22210009844c71cc9/1903_Samples/Shared_Components/Managed_WinRT_Comp/Controls_Pages/MediaPage.xaml.cs#L22

The MainPage is a XAML User control that is loaded into the WPF Xaml Host. https://github.com/marb2000/XamlIslands/blob/362cdc62e3257156e3b19ce22210009844c71cc9/1903_Samples/WPF_Core3_App/MainWindow.xaml#L11

I can't reference directly the SwapChainPanel into the WindowsXamlHost, it fails (it is on-investigation right now), meanwhile you can create a Grid:

<xamlhost:WindowsXamlHost InitialTypeName="Windows.UI.Xaml.Controls.Grid"  />

and add the SwapChainPanel in the code behind.

marb2000 commented 5 years ago

The WPF sample demonstrates who to use SwapChainPanel.