Experimental Mobile Blazor Bindings - Build native mobile apps with Blazor
Перейти к файлу
Eilon Lipton 8d216a91f4 Make sure error page is run on UI thread 2019-10-07 16:44:51 -07:00
.vscode Add Azure pipelines YML 2019-09-24 10:49:11 -07:00
azure-pipelines Remove YAML comments 2019-10-03 16:57:45 -07:00
samples Try to fix AzDO build again 2019-10-03 10:07:18 -07:00
src Make sure error page is run on UI thread 2019-10-07 16:44:51 -07:00
tools Add Library.Template tools 2019-09-24 11:20:43 -07:00
.editorconfig Create .editorconfig 2019-09-17 12:08:31 -07:00
.gitattributes Add initial code from Steve 2019-08-02 16:49:21 -07:00
.gitignore Add missing azure-pipelines/artifacts folder 2019-10-03 12:50:41 -07:00
CONTRIBUTING.md Add Azure pipelines YML 2019-09-24 10:49:11 -07:00
Emblazon.sln Add Azure pipelines YML 2019-09-24 10:49:11 -07:00
LICENSE Add Azure pipelines YML 2019-09-24 10:49:11 -07:00
Readme.md Add NuGet feed info 2019-10-04 10:44:04 -07:00
azure-pipelines.yml Remove code coverage steps 2019-09-24 11:51:00 -07:00
global.json Update to .NET Core 3 RTM 2019-09-23 11:37:30 -07:00
init.cmd Add Azure pipelines YML 2019-09-24 10:49:11 -07:00
init.ps1 Change dotnet restore path 2019-09-24 11:26:41 -07:00
nuget.config Update to latest NuGet packages 2019-09-04 16:54:49 -07:00
version.json Add Azure pipelines YML 2019-09-24 10:49:11 -07:00

Readme.md

Emblazon - Home of Blaxamarin and BlinForms

Build Status

What is Emblazon?

Emblazon enables using Blazor to target native UI renderers (as opposed to web/HTML renderers). This repo contains implementations that target Xamarin.Forms and Windows Forms.

Start Emblazoning!

Required software to use Emblazon and for contributors

Emblazon and its related projects require:

  1. Visual Studio 2019 16.3 or newer
    • For Blaxamarin, the Xamarin workload must be enabled in Visual Studio
    • For BlinForms, you must run on Windows (that's the in of BlinForms!)
  2. .NET Core 3.0 SDK

Create a Blaxamarin project

  1. In Visual Studio, create a Xamarin.Forms Mobile App project

  2. Select the Blank app template

  3. Add the Emblazon NuGet package feed by adding a new NuGet.config file to the solution directory:

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <packageSources>
        <add key="Emblazon Feed" value="https://devdiv.pkgs.visualstudio.com/_packaging/Emblazon/nuget/v3/index.json" />
        </packageSources>
    </configuration>
    
  4. In the solution's shared project (the one that isn't Android or iOS), make these changes:

    1. Change the top <Project> node to use the Razor SDK <Project Sdk="Microsoft.NET.Sdk.Razor">
    2. In the <PropertyGroup> section, add this node to set the Razor language version: <RazorLangVersion>3.0</RazorLangVersion>
    3. Add a reference to Blaxamarin in the <ItemGroup> containing other package references: <PackageReference Include="Blaxamarin.Framework" Version="0.1.54-beta" /> (update to a newer build as needed)
    4. Delete MainPage.xaml and MainPage.xaml.cs
    5. Delete App.xaml and App.xaml.cs
    6. Add a new class file called App.cs to the project
    7. Add these using statements:
    using Blaxamarin.Framework;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    using Xamarin.Forms;
    
    1. Replace the app class's code with this code:
     public class App : Application
     {
         public App()
         {
             var host = Host.CreateDefaultBuilder()
                 .ConfigureServices((hostContext, services) =>
                 {
                     // Register app-specific services
                 })
                 .Build();
    
             host.Services.AddComponent<MainPage>(parent: this);
         }
    
         protected override void OnStart()
         {
             // Handle when your app starts
         }
    
         protected override void OnSleep()
         {
             // Handle when your app sleeps
         }
    
         protected override void OnResume()
         {
             // Handle when your app resumes
         }
     }
    
    1. Add a Razor Component to the project named _Imports.razor with these contents:
     @using Blaxamarin.Framework.Elements
     @using Xamarin.Forms
    
    1. Add a Razor Component to the project named MainPage.razor
     <ContentPage>
         <StackLayout>
             <Button Text="Add!" OnClick="@OnAdd" />
             <Label Text="@($"The button has been clicked {counter} times!")" />
         </StackLayout>
     </ContentPage>
    
     @code {
         int counter;
    
         void OnAdd()
         {
             counter++;
         }
     }
    
  5. You're ready to go! Run the Android or iOS project to launch your new Blaxamarin-based app!

NuGet feed

Browse the latest packages here: https://devdiv.visualstudio.com/Personal/_packaging?_a=feed&feed=Emblazon

Solution structure

There are 3 main areas:

  1. Emblazon - Base framework for Blazor rendering to native UI frameworks.
  2. BlinForms - Blazor rendering to Windows Forms.
  3. Blaxamarin - Blazor rendering to Xamarin.Forms.

Comparison projects

To compare Blaxamarin with Xamarin.Forms, see the Xamarin.Forms Todo XAML sample.