简体   繁体   中英

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.

I should use Xamarin forms with MVVM Light , but with a large part of native pages (UWP). For this, I wondered if I had to place my View-Models in the portable class or in the UWP Project ? 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.

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)

  2. DependencyService as described here 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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