Multi-Targeting with Class Libraries containing Resource Dictionaries

40 Views Asked by At

Is there any possible way to create a multi-targeted class library containing a ResourceDictionary that for both WinUI 3 and WinUI 2? Has it been tried for WPF?

The tutorials I found just approach the creation of a simple package that contains code to sum two numbers, but nothing related to UI. I've done a lot of research on the subject and several tests, but maybe someone has tried something similar and give me a definite answer if it is feasible.

If you have any advice you can give me, it is much appreciated!

I tried creating a shared csproj file with the different target frameworks, but the configuration for each project is very different. I added the conditional ItemGroups to add the respective dependencies.

1

There are 1 best solutions below

0
Katana On

You should create a seperate dll or nuget package for every platform (winui2/3) You cant use a single package for both, however you can use a resourceDictionary/class for both. For starting point you can take a look at communitytoolkit repo which there is a single code-base with multiple platform. (Winui2/3 and uno) https://github.com/communitytoolkit/windows