Multitarget UWP usercontrol for WinUI and UWP

76 Views Asked by At

I would like to multitarget my UserControl for both UWP and WinUI.

I found this link: https://nicksnettravels.builttoroam.com/upgrade-uwp-to-winui/ but it is really hard to migrate all the features because my project is a bit bigger and also sorting and adding using directives for both WinUI and UWP is an annoying job. I really hope there is a better way.

Is there any simple way or a tool that could do this?

2

There are 2 best solutions below

1
Andrew KeepCoding On BEST ANSWER

I'm not sure if there's a simple way to multi-target UWP and WinUI. But I'm sure that I wouldn't do so. These are the reasons that comes to mind.

  • UWP and WinUI use different namespaces.
  • Latest (and future) .NET doesn't support UWP, so your code will be stuck with old .NET.
  • Even the WindowsCommunityToolkit has two different solutions for UWP and WinUI, so I guess there's no simple way to multi-target UWP and WinUI.
0
Roy Li - MSFT On

Currently, there is no easier way to do this. UWP and WinUI3 apps looks very similar to each other, but they are actually different products. This is already mentioned in @Andrew KeepCoding's answer. So if you need to multitarget your code for both UWP and WinUI3, these works are necessary.