Posts

Xamarin Forms: Embedding native controls and still have XAML compilation for the Page

Image
Embedding native controls Skip this part if you know what the embedding native controls is In Xamarin Forms, with native control embedding, you can put native controls (i.e. native Android or iOS controls) on your Xamarin Forms pages. It’s very simple and the official Xamarin Forms documentation (link here ) explains how to achieve it. Here’s an example of using native embedding in XAML: < ContentPage xmlns="http://xamarin.com/schemas/2014/forms"         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"         xmlns:ios="clr-namespace:UIKit;assembly=Xamarin.iOS;targetPlatform=iOS"         xmlns:androidWidget="clr-namespace:Android.Widget;assembly=Mono.Android;targetPlatform=Android"         xmlns:androidLocal="clr-namespace:MyApp.Droid;assembly=MyApp.Droid;targetPlatform=Android"         x:Class=" MyApp.MyContentPage " >            ...

Xamarin.Forms XmlnsDefinition attribute: All of your namespaces become one

Image
When working on a mobile app developed with Xamarin Forms ( if  you aren’t, you’re missing all the fun! ) you might have your own awesome separate library project   of custom controls, effects, behaviors, value-converters, constants: You’ve might not been very happy ( to put it nicely ) how you're using your library objects in your app’s XAML, having to deal with all the different XML namespaces and prefixes: So many prefixes and namespaces to handle!  Yikes! The issue is not just about declaration of prefixes. Having separate prefixes bloats the XAML a lot because you have to use a separate prefix for every object you reference from the corresponding namespace. In my example there are 4 prefixes to deal with! As a solution to get rid of all the namespaces, a dark thought might have crossed your mind: remove all the CLR namespaces in the library’s code and just have one namespace! But you love your C# namespaces, they give class scope and separation, it’s...

Bindable layouts, one of my contributions to the Xamarin.Forms framework

Image
Xamarin, Microsoft-owned for few years now, asked me to write on their blog a guest post about bindable layouts , one of my contributions to the Xamarin Forms framework, an awesome open-source cross-platform framework for developing mobile apps. After finishing the implementation, I submitted a pull-request for it and, lo and behold, the Xamarin.Forms team accepted it! Contributing to a large framework as Xamarin.Forms can take lot of blood and sweat sometimes but it’s a lot of fun. Here’s the blog post I wrote on Xamarin's blog which describes the bindable layouts feature: https://blog.xamarin.com/xamarin-forms-3-5-a-little-bindable-love/ ...just posted on the Xamarin Blog, Andrei Nitescu shares one of his contributions to Xamarin.Forms, the bindable layout. Starting with Xamarin.Forms 3.5.0 pre2, we can use the BindableLayout set of attached properties on any Layout<T> view. Learn more: https://t.co/zhLzBKRWPa pic.twitter.com/hVtVjjqN20 — Xamarin (@xamarinhq)...

Xamarin Forms: Lazy load the tabs in TabbedPage

Too much fun with Xamarin Forms

Image
I had a blast playing with Xamarin Forms and SVGs which end up with the following which works on iOS, Android and Windows UWP, checkout the videos for Android and iOS apps: Credit for original design idea goes to Mikael Ainalem: https://twitter.com/mikaelainalem/status/963076814183772160 The SVG is created dynamically, based on the position of the text-boxes and the button, so it will work on any number of text-boxes and buttons. The actual SVG for the login screen in the videos, looks like this:

Debugging HTML5 running in iOS from Windows with Chrome dev tools!

Image
In order to debug HTML5 running in Safari on iOS, I used to connect the iOS device to my Mac, open Safari, go to Developer menu(needs to be activated from Safari Preferences) and open the page. You can find detailed steps how to do this on internet. I tried to remote debug HTML5 with other tools (Telerik has one), but the best way is with an utility called  ios-webkit-debug-proxy  which uses Chrome dev tools! You can find it here  https://github.com/google/ios-webkit-debug-proxy  and its Windows port: https://github.com/artygus/ios-webkit-debug-proxy-win32 It allows you inspect the WebKit (either the Safari or UIWebViews) running on the iOS device from your Windows machine with Chrome dev tools. This utility connects to the WebKit for inspection. Steps (most of these are written in https://github.com/google/ios-webkit-debug-proxy ): Go to  https://github.com/artygus/ios-webkit-debug-proxy-win32 You can either get the compiled version or build from the source. I ...

GridSplitter control for Xamarin Forms

Image
I created a GridSplitter control for Xamarin Forms, which works on iOS and Android. You can find the full description of how it works and how to include it in your app: https://github.com/andreinitescu/GridSplitterApp Here are some screenshots of the demo app: and a Grid with both horizontal and vertical splitters: The sample app also shows a technique to create reusable custom controls which you can style easily, very similar to how it works in WPF/UWP.