简体   繁体   English

WinUI 的多目标 UWP 用户控件和 UWP

[英]Multitarget UWP usercontrol for WinUI and UWP

I would like to multitarget my UserControl for both UWP and WinUI.我想将我的 UserControl 用于 UWP 和 WinUI。

I found this link: https://nick.nettravels.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.我找到了这个链接: https://nick.nettravels.builttoroam.com/upgrade-uwp-to-winui/但是真的很难迁移所有功能,因为我的项目有点大,而且还要排序和添加使用指令WinUI 和 UWP 都是一个烦人的工作。 I really hope there is a better way.我真的希望有更好的方法。

Is there any simple way or a tool that could do this?有什么简单的方法或工具可以做到这一点吗?

I'm not sure if there's a simple way to multi-target UWP and WinUI.我不确定是否有一种简单的方法可以多目标 UWP 和 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. UWP 和 WinUI 使用不同的命名空间。
  • Latest (and future) .NET doesn't support UWP, so your code will be stuck with old .NET.最新(和未来).NET 不支持 UWP,因此您的代码将停留在旧的 .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.即使是 WindowsCommunityToolkit 也有针对 UWP 和 WinUI 的两种不同的解决方案,所以我想没有简单的方法可以多目标 UWP 和 WinUI。

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. UWP和WinUI3 apps看起来很像,其实是不同的产品。 This is already mentioned in @Andrew KeepCoding's answer. @Andrew KeepCoding 的回答中已经提到了这一点。 So if you need to multitarget your code for both UWP and WinUI3, these works are necessary.因此,如果您需要将代码同时用于 UWP 和 WinUI3,则这些工作是必要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM