是否可以创建平台特定的视图?
在UWP中,可以通过将这些视图放入各自的文件夹中或将相关设备名称附加到文件名来创建设备特定视图。 我看不到任何与毛伊岛相当的信息,因为平台特定视图仅平台特定代码。 这是一回事吗?
我能获得的最接近的是使用预处理器指令并给出文件独特的名称。这意味着不幸的是,文件背后仍然有多个代码。
所以 -
#if Android
await Navigation.PushAsync(new Page1Windows());
#elif Windows
await Navigation.PushAsync(new Page1Android());
#endif
In UWP, device specific views can be created by placing those views into their respective folders or appending the relevant device name to the file name.
I don't see any information on doing the equivalent with MAUI as regards platform specific views only platform specific code.
Is this a thing ?
The closest I can get is using preprocessor directives and giving the files unique names. This means there are still multiple code behind files unfortunately.
So -
#if ANDROID
await Navigation.PushAsync(new Page1Windows());
#elif WINDOWS
await Navigation.PushAsync(new Page1Android());
#endif
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一回事。
默认的MAUI项目提供了一个特定平台的文件夹,您可以将平台特定的代码放入中。
如果您想要更复杂的内容,例如平台命名的文件夹或文件,则可以编辑您的CSPROJ以包含或排除文件&平台。
配置多刻录文档:
这是组合文件名和文件夹多目标不包括包括不匹配当前目标的平台名称的文件和文件夹。
It's a thing.
The default MAUI projects provide a platform specific folder you can put platform specific code in.
If you want something more complicated, like your platform-named folders or files, you can edit your csproj to include or exclude files by name & platform.
There are examples of both file and folder-based targeting in the Configure multi-targeting docs:
Here's the combined view from Combine filename and folder multi-targeting that excludes files and folders that include platform names that don't match the current target.