BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Blazor Makes Its Way Into Cross-Platform Mobile App Development

Blazor Makes Its Way Into Cross-Platform Mobile App Development

Officially announced at the "Focus on Blazor" .NET Conf, Blazor's Mobile Bindings are a new experimental project aimed to enable cross-platform mobile app development using Microsoft Blazor and .NET for iOS and Android. Similarly to React Native, Mobile Blazor Binding use native UI controls, thus enabling a native look and feel.

In a nutshell, Mobile Blazor Bindings extend the Blazor programming model for mobile development. As Microsoft .NET engineer Eilon Lipton wrote, this will be of specific interest to XAML and Xamarin developers who have been using XAML, Razor templates, and Xamarin to build mobile hybrid apps or to those using Blazor to create Web apps.

The goal of these bindings is to see if developers would like to have the option of writing markup and doing data binding for native mobile applications using the Blazor-style programming model with Razor syntax and features.

As an example of how natural the writing of a mobile app using Mobile Blazor Bindings should feel for web developers with some experience in Razor, Lipton presented the following snippet defining a simple view with a button and a tap-counter:

<StackLayout>
    <Label FontSize="30"
           Text="@("You pressed " + count + " times")" />
    <Button Text="+1"
            OnClick="@HandleClick" />
</StackLayout>

@code {
    int count;

    void HandleClick()
    {
        count++;
    }
}

(Credits: Microsoft)

The above snippet shows the use of Xamarin.Forms StackLayout along with native C# code to handle UI behaviour as it is usual in Razor components for hybrid apps. The same simple view for a Web app would use a similar code structure, but the UI would be described using HTML instead of Xamarin.Forms markup.

Mobile Blazor Bindings are an attempt to expand Blazor into a full-stack development framework, as Microsoft explained at its .NET Conf 2019 conference. The following image helps to clarify the different dimensions Blazor is moving through and where the Mobile Blazor Bindings fit it.

(Credits: Microsoft)

Microsoft's announcement raised both positive and negative reactions among developers. Besides those welcoming the new addition to the Blazor toolbox, several developers expressed concerns over the multiplication of options to create UI using .NET technologies. This makes it hard to choose which one to invest in and train a team into. Others went so far as expressing their fears Microsoft will at some point kill some of those projects, leaving the developers who adopted them in the dust.

More factually, some critical voices focused on the fact Blazor Web and mobile apps would not share the same UI definition, thus diminishing the value of using a single programming model across both platforms. Additionally, they expressed a wish for Microsoft to focus on Blazor for Progressive Web Apps and WebAssembly, leaving mobile development to WPF, UWP and Xamarin.

Blazor runs on .NET Standard 2.0 and relies on Xamarin.Forms for its native UI components. Mobile Blazor Bindings are available on GitHub and require .NET Core 3.0 or 3.1.

Rate this Article

Adoption
Style

BT