erikrunia
erikrunia

Reputation: 2383

How to use CommunityToolkit.Maui DrawingView inside of a Maui Blazor App

I'm new to Maui Blazor, using it as I'm more comfortable with Razor pages from my MVC days than XAML. I've created the default Maui Blazor application in VS 2022 and it seems to generate one XAML file that points to the Blazor stuff like so:

<BlazorWebView HostPage="wwwroot/index.html">
    <BlazorWebView.RootComponents>
        <RootComponent Selector="#app" ComponentType="{x:Type local:Main}" />
    </BlazorWebView.RootComponents>
</BlazorWebView>

However all the examples of using the DrawingView from the community toolkit (i'm using version 2.0 to support .net 6) seem to be with XAML and not Blazor, like so:

  1. Add the namespace in your Xaml:

xmlns:views="clr-namespace:CommunityToolkit.Maui.Views;assembly=CommunityToolkit.Maui"

  1. Finally, consume it in your Xaml like below:

         <views:DrawingView
             x:Name="DrawView"
             BackgroundColor="LightGray"
             WidthRequest="200"
             HeightRequest="200"
             IsMultiLineModeEnabled="True"
             LineColor="Red"
             LineWidth="1"
             HorizontalOptions="Center" />
    

Can someone show me how to use the Drawing View in my .razor implementation instead of in the XAML?

Upvotes: 0

Views: 931

Answers (1)

Alexandar May - MSFT
Alexandar May - MSFT

Reputation: 10078

The .NET MAUI Community Toolkit is a collection of reusable elements for application development with .NET MAUI, including animations, behaviors, converters, effects, and helpers. In .NET MAUI Blazor, I tried to use the Drawing View in .razor page. Unfortunately, it failed to render the Drawing View like in .NET MAUI.

I would suggest that you can open a New Feature Proposal on Github to propose a suggestion on supporting the Drawing View in .razor page.

Upvotes: 1

Related Questions