Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
36
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

Chapter 13 Lets Get Graphical

Registering Your Widget

The last part in your implementation of the sketch widget is to register your view and view model with the MauiAppBuilder. Let’s open up the MauiProgram.cs file and add the following lines into the

CreateMauiApp method:

WidgetFactory.RegisterWidget<SketchWidgetView, SketchWidgetView Model>(SketchWidgetViewModel.DisplayName); builder.Services.AddTransient<SketchWidgetView>(); builder.Services.AddTransient<SketchWidgetViewModel>();

Taking Your Widget for a Test Draw

You should be able to run your application on all platforms, add a widget of type Sketch to a board, and then interact with the widget to leave a fancy doodle. Figure 13-3 shows the new sketch widget rendered on a board.

Figure 13-3.  The sketch widget showing my terrible doodling skills running on macOS

404