![]() |
|
Unified Blazor UI in the Mobile Blazor Bindings Preview 5 - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: C#, Visual Basic & .NET (https://sickgaming.net/forum-79.html) +--- Thread: Unified Blazor UI in the Mobile Blazor Bindings Preview 5 (/thread-98048.html) |
Unified Blazor UI in the Mobile Blazor Bindings Preview 5 - xSicKxBot - 10-31-2020 Unified Blazor UI in the Mobile Blazor Bindings Preview 5 Eilon October 30th, 2020 I’m excited to announce that today we are releasing the Mobile Blazor Bindings Preview 5 update that adds support for sharing UI between web apps and mobile/desktop apps. You can now use a Razor Class Library (RCL) to build your UI and app logic once and use it in a Blazor Web app and in a Mobile Blazor Bindings app. This release also includes many other improvements, such as support for Shell with Blazor Code: @pageYou can build one UI using Blazor Web and host it in a Blazor Server or Blazor Web Assembly app and also in a Mobile Blazor Bindings hybrid app to target Android, iOS, macOS, and Windows: These are the major new features in the 0.5 Preview 5 release:
Get started To get started building a Blazor Hybrid app with Experimental Mobile Blazor Bindings preview 5, install the .NET Core 3.1 SDK, have Visual Studio with the Mobile development with .NET (Xamarin.Forms) and ASP.NET and web development workloads installed, and then run the following command: Code: dotnet new -i Microsoft.MobileBlazorBindings.Templates::0.5.50-previewAnd then create your first project by running this command: Code: dotnet new blazorhybrid -o MyHybridAppNote: For additional information on required software, please check the Getting Started article. Now open it in Visual Studio and run it on Android, iOS, Windows, or macOS. That’s it! You can find additional docs and tutorials on https://docs.microsoft.com/mobile-blazor-bindings/. We have a new tutorial for building a Razor Class Library and including it in a Blazor Server app as well as targeting Android, iOS, macOS, and Windows platforms. Upgrade an existing project To update an existing Mobile Blazor Bindings project please refer to the Migrate Mobile Blazor Bindings From Preview 4 to Preview 5 topic for full details. Razor Class Library support Razor Class Libraries are a feature of Razor that enable you to package part of your application’s UI and logic into a reusable library. This library can then be reused in multiple web applications. Now in Mobile Blazor Bindings you can use the same library in a Blazor Hybrid application as part of a mobile or desktop app. The web content is hosted in a Web View, just like any hybrid app content, and it can interact with any native parts of the application, and the reverse is true as well. Previous versions included limited support for RCLs, and this version adds improved support for them, particularly support for serving static assets such as CSS and images, as well as support for Code: JSInteropShell navigation To build a great native experience for your app you can use the Shell control that comes from Xamarin.Forms. Starting with Preview 5 you can author native Blazor pages with the Code: @page "/search/{query}"Code: NavigationManager.NavigateToAsync($"/search/{query}")Code: @inject ShellNavigationManager NavigationManagerSkiaSharp graphics SkiaSharp is a popular cross-platform graphics library based on Google’s Skia graphics library. In Preview 5 you can directly use SkiaSharp’s Canvas APIs to render rich high-performance graphics directly in your Mobile Blazor Bindings app. Here’s what a simple canvas might look like: Code: <ContentView> <StackLayout Padding="20"> <SKCanvasView OnPaintSurface="PaintSurface"/> </StackLayout>
</ContentView> @code
{ void PaintSurface(SKPaintSurfaceEventArgs e) { var canvas = e.Surface.Canvas; canvas.Clear(SKColors.Green); var paint = new SKPaint { Color = SKColors.SkyBlue, }; canvas.DrawLine(0, 0, 200, 200, paint); }
}And here’s what a more complex canvas might render as: More information Thank you to contributors This release had several major contributions from community contributors:
Thanks you to Jan-Willem, Lachlan, and everyone else who contributed to this release! What’s next? Let us know what you want! This project relies on your feedback to help shape the future of Blazor for native and hybrid scenarios. Please share your thoughts on this blog post or at the GitHub repo so we can keep the discussion going. |