Currently we trying to improve our existing WPF application UI. For that, we are trying to use the WinAppSDK to use the Winui3 controls.
Steps followed.
Created a new WPF application Installed the latest version of WinAppSDK from the Nuget package
Refered the winUI controls by including the XAMLControlResources in the APP.Xaml
But i am unable to access the controls from the Microsoft.UI.XAML. It says doesnt exist.
Please advice whether i am trying with the right way of approach .
App.XAML
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:controls1="clr-namespace:ABI.Microsoft.UI.Xaml.Controls;assembly=Microsoft.WinUI"
StartupUri="MainWindow.xaml">
<Application.Resources>
<controls1:XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" x:Key="winAppControl"/>
</Application.Resources>
</Application>
MainWindow.Xaml
<Window x:Class="WpfApp2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
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;assembly=Microsoft.WinUI"
xmlns:local="clr-namespace:WpfApp2"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800"
<muxc:TreeView>
<muxc:TreeView.RootNodes>
<muxc:TreeViewNode Content="Flavors">
<muxc:TreeViewNode.Children>
<muxc:TreeViewNode Content="Vanilla"/>
</muxc:TreeViewNode.Children>
</muxc:TreeViewNode>
</muxc:TreeView.RootNodes>
</muxc:TreeView>
</Window>
I am getting error as resource not found
As Simon Mourier mentioned already, WinUI 3 and WPF are completely different technologies. You cannot mix them that easily since they use completely different technologies to render controls (e.g. WPF is .NET only while WinUI 3 is written in C++/WinRT).
The only solution would be to use XAML Islands, however they are not available for WinUI 3 as part of the stable releases. As of right now, the only way to do that would be to use experimental releases of WinUI 3 but even then, it's unclear if it will be brought to the stable release channel any time soon (or at all).