

See the ListImageCell? He's subclassed ImageCell, which is a TextCell with an Image, and setup data binding for the text and the icon. ListView.SelectedItem = viewModel.MenuItems ListView.ItemsSource = viewModel.MenuItems Var cell = new DataTemplate(typeof(ListImageCell)) Ĭell.SetBinding (TextCell.TextProperty, HomeViewModel.TitlePropertyName) Ĭell.SetBinding (ImageCell.ImageSourceProperty, "Icon") Var layout = new StackLayout įont = Font.SystemFontOfSize (NamedSize.Medium) I've simplified a little for clarity, but the idea is all MVVM: public HomeMasterView(HomeViewModel viewModel)

Here is the menu that switches between views:Īnd the code that creates it. This little app is written in C# and runs natively on Windows Phone, Android, and iOS. My buddy from Xamarin, James Montemagno, a fellow Chipotle lover, put together the ultimate cross-platform Hanselman application in a caffeinated late night hack to illustrate a few points for me. So a "tab" in my code is expressed in its most specific and native counterpart on the mobile device, rather than as a generic tab control as in my Java example. What's interesting about this, to me, is that these "control/concepts" (my term) are coded at a high level but rendered as their native counterparts. It provides more than 40 cross-platform controls and layouts which are mapped to native controls at runtime, which means that your user interfaces are fully native." "Xamarin.Forms is a new library that enables you to build native UIs for iOS, Android and Windows Phone from a single, shared C# codebase. This, to my old eyes, is very similar to the way I wrote code in Java back in the day - it was all done in a fluent code-behind with layouts and flows. Xamarin announced Xamarin.Forms today which (in my words) effectively abstracts away native controls to a higher conceptual level. This is desirable in many cases, but for some app it's just boring, error prone, and tedious. However, even for simple apps you've still got to create a custom native view for each platform. With MVVM (Model, View, View-Model) patterns, and techniques like the Universal apps work on Windows Phone 8.1 and Windows 8.1, code sharing can get up into the high 90% for some kinds of apps.

They didn't integrated with the underlying platform. This meant that the app pretty much worked everywhere, but the app always LOOKED like a Java App. We used to use Spy++ and different Windows inspector programs to explore our applications and they could never see a Java program's controls.

We used to joke that we'd "write once, debug everywhere." Now, this was the early days of Java, but the thing was, every form and control was 'owner drawn.' That meant that a button looked the same everywhere because it wasn't a real button as far as the operating system was concerned. I worked in Java for a number of years at Nike, writing an order management application that would run on four platforms.
