Can I use winUI 3 class library to WPF ?

mehmet yılmaz 20 Reputation points
2023-08-29T12:18:02.3233333+00:00

I want to port my wpf app to uno platform because of uno compatible with winUI 3 xaml. So it will be easy to porting to uno. Can I use winUI 3 class library to WPF ?

Developer technologies | Windows Presentation Foundation
Windows development | Windows App SDK
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 48,676 Reputation points Microsoft External Staff
    2023-08-30T03:10:12.6833333+00:00

    Hi,@mehmet yılmaz . Welcome Microsoft Q&A.

    You could use a WinUI 3 class library in a WPF application, but with certain considerations.

    WinUI 3 is targets Windows App SDK, while WPF is a separate framework with its own set of controls and runtime. While WinUI 3 and WPF share some common XAML concepts, they are not directly interchangeable.

    And WinUI 3 is part of the Windows App SDK—so, naturally, a WinUI 3 app can use the other Windows App SDK features and APIs, as well. For how you can use Windows App SDK APIs (and Windows Runtime APIs) in a WPF app, you could refer to the document Use the Windows App SDK in a WPF app.

    Here are a few points to consider:

    UWP Control Compatibility: If you're using WinUI 3 controls in a UWP app, the Uno Platform should provide good compatibility. However, if you're looking to use WinUI 3 controls in a WPF app, you might run into issues because WPF and UWP have different application models, layout systems, and runtime environments.

    WPF and Uno Platform: While Uno Platform aims to bring UWP features to other platforms, including WPF might not be a straightforward process. It's best to consult the Uno Platform documentation and resources to understand their compatibility and recommended practices for different scenarios.

    Porting to Uno Platform: If your goal is to port your WPF app to Uno Platform for cross-platform compatibility, you'll likely need to adapt your UI code, as well as any platform-specific features or APIs you're using. While some code and XAML might be reusable, there might still be platform-specific adjustments required.

    WinUI 3 and WPF: If you want to use WinUI 3 controls in a WPF app, it might be more practical to look for equivalent controls or solutions that are native to WPF.


    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.


  2. Castorix31 90,681 Reputation points
    2023-09-07T07:57:40.23+00:00

    If you want to use WinUI 3 controls inside a WPF app, you can now use XAML Islands, which has just been released : https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/stable-channel#xaml-islands-no-longer-experimental

    I uploaded a sample in WPF/C# : WPF_XAML_Islands_WinUI3

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.