简体   繁体   English

Xamarin.Forms中的本地页面

[英]Native Page in Xamarin.Forms

I apologize in advance for my question, but I start with Xamarin and need help to create a particular architecture. 我提前为我的问题道歉,但我从Xamarin开始,需要帮助来创建一个特定的架构。

I should use Xamarin forms with MVVM Light , but with a large part of native pages (UWP). 我应该在MVVM Light中使用Xamarin表单,但是使用大部分本机页面(UWP)。 For this, I wondered if I had to place my View-Models in the portable class or in the UWP Project ? 为此,我想知道是否必须将View-Models放在便携式课程或UWP项目中? And if in the portable class, what navigation use to navigate between my native pages ? 如果在便携式课程中,导航用于在我的原生页面之间导航?

The Logic should be placed inside the shared code so put your ViewModels inside the portable or shared project. 逻辑应放在共享代码中,以便将ViewModel放在可移植或共享项目中。

For navigation between pages you could use: 要在页面之间导航,您可以使用:

  1. conditional compilation 条件编译

    if mobile navigation droid/iOS else navigation UWP (Use with underscores, entering here is using formatting, see link Condotional Compilation for more details) if mobile navigation droid/iOS else navigation UWP (使用下划线,进入这里使用格式,请参阅链接Condotional Compilation了解更多详情)

  2. DependencyService as described here DependencyService DependencyService,如此处所述DependencyService

I'm sure there are other ways but I think DependencyService is the most elegant, as those #if#else stuff makes the code confusing and unreadable. 我确信还有其他方法,但我认为DependencyService是最优雅的,因为那些#if #other东西会使代码混乱且难以理解。

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

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