简体   繁体   中英

Xamarin Layout vs Xamarin Forms ContentPage XAML

SO I'm new in mobile dev and in xamarin.

So I try to understand - If I need some view(pages) with different content and logic - how is right way to do it?

1) Create a ContentPage Xaml

2) Or create a layout and class where I just write logic and write

SetContentView (Resource.Layout.LAYOUTNAME);

I'm web developer ( ASP ) so if you can draw a parallel with web - its be nice.

Like:

How I see - second way ( class + layout ) - its like

Controller in asp and page with clean html

first way ( ContentPage XAML ) - its most similar for WebForms or for WPF (and really i hate it)

But I want to know what is right way and best practice?

Thank you

If you use Xamarin.Forms Xaml is converted to native UI when you compile and the app packages are created. In Xamarin.Forms you should use Android Layouts and iOS Story Boards only if you need something very specific for the platform you target.

If you prefer use Android Layouts and iOS StoryBoards it will be better use a native Project template (Non Xamarin.Forms project) and you can create the UI in the specific platfom projects and only share the business logic.

Xamarin.Forms is a UI framework and it helps to share UI logic using xaml.

Xamarin方法

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