Using an XAML Island in a WPF Project.

RogerSchlueter-7899 1,196 Reputation points
2022-09-18T23:57:01.313+00:00

This thread is an improved, specific version of this question. Here I will demonstrate how to reproduce the issue which will hopefully allow for answers to result.

Here are the steps:

  1. Open a new wpf project.
  2. Using Nuget, add "Microsoft.Toolkit.Wpf.UI.Controls". Building the project gives this error: "SupportedOSPlatformVersion 10.0.18362.0 cannot be higher than TargetPlatformVersion 7.0"
  3. Searching for that error message yields thus page.
  4. Following those directions, I modified my project file to include this line: <TargetFramework>net6.0-windows10.0.22000.0</TargetFramework> (I am running on Windows 11).
  5. Now building the project yields this error: Microsoft.Toolkit.Win32.UI.XamlHost.Managed.dll cannot be referenced because it uses built-in support for WinRT, which is no longer supported in .NET 5 and higher. An updated version of the component supporting .NET 5 is needed. For more information, see https://aka.ms/netsdk1149 C:\Program Files\dotnet\sdk\6.0.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets 1007
  6. The web site listed in that error message is of no value.

How do I resolve this issue?

Universal Windows Platform (UWP)
Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,669 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 38,191 Reputation points Microsoft Vendor
    2022-09-19T05:50:16.37+00:00

    Hi,@RogerSchlueter-7899 . I reproduced your problem.

    From my research, .NET 6 doesn't seem to support XAML islands. As said Use XAML Islands to host a UWP XAML control in a C# WPF app

    Using XAML Islands (wrapped controls or WindowsXamlHost) to host UWP XAML controls is supported only in apps that target .NET Core 3.x. XAML Islands are not supported in apps that target .NET, or in apps that target any version of the . NET Framework.

    And there is XAML Islands for .NET 5 , where .NET 6 seems to be added, but I haven't tested it. If you want to use it in .NET 6.0, you could submit an issue in the Github.

    ----------------------------------------------------------------------------

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful