0

I am trying to use new WinUI toolkit TreeView/TeachingTip/... control to my UWP Application. I have added the references Microsoft.UI.Xaml from Nudget packages.

<Page 
    x:Class="UWPInVS2019.Login"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:UWPInVS2019"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:WinCon="using:Microsoft.UI.Xaml.Controls"
    mc:Ignorable="d" 
>
<Grid>
<Button />
<WinCon:TeachingTip/>
</Grid>

I am getting the below error message enter image description here

Dean Chalk
  • 20,076
  • 6
  • 59
  • 90

1 Answers1

2

The problem is that you miss adding XamlControlsResources to the UWP project App.xaml file. Please add the following xaml code into App.xaml file.

<Application>
    <Application.Resources>
        <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
    </Application.Resources>
</Application>

For more detail, please refer WinUI official tutorial.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • I have added the XamlControlsResources to App.Xaml .Its works Fine now. – sridhar patro Apr 30 '20 at 20:05
  • If I add the XamlControlResources in app.xaml the default styles of controls(Button ) of UWP application get updated to WinUI controls styles(i.e rounded corner). Without adding the XamlControlResources to App.Xaml Is there any way to add extra controls(teaching tip/treeView) of WinUI to UWP application. My aim is to use the UWP controls and use the extra controls that where used in WinUI. – sridhar patro Apr 30 '20 at 20:15
  • TreeView available in 1809, if we edit the min target version to 1809, you could use TreeView directly. – Nico Zhu May 04 '20 at 01:19
  • @NicoZhu-MSFT I have similar issue posted [here](https://stackoverflow.com/q/62963136/1232087) if you have some time for a suggestion/comment. – nam Jul 17 '20 at 23:50