Dreamescaper / BlazorBindings.Maui

MAUI Blazor Bindings - Build native and hybrid MAUI apps with Blazor
MIT License
251 stars 23 forks source link

Question: Class libraries #129

Closed mrpmorris closed 1 year ago

mrpmorris commented 1 year ago

Thanks for this library. I am just evaluating it at the moment, but it looks great!

Do you have instructions for how I can create a class library? I don't see a template for it, so this is what I did

1: Created another new app 2: Reduced the csproj to the following

<Project Sdk="Microsoft.NET.Sdk.Razor">

    <PropertyGroup>
        <TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
        <RootNamespace>DSMauiComponents</RootNamespace>
        <UseMaui>true</UseMaui>
        <EnableDefaultCssItems>false</EnableDefaultCssItems>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="BlazorBindings.Maui" Version="0.10.40-preview" />
    </ItemGroup>

</Project>
  1. Referenced it from my main app

When I use a component in that class library I get an error telling me there can only be one root element in the app, even though it is added inside the VerticalStackLayout in the default main page (just about the counter button).

mrpmorris commented 1 year ago

Doh, I was automatically adding stupid markup in my component

<h1>Hello</h1>

:D