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

Chapter 8 Advanced UI Concepts

Creating ShowOverlayTriggerAction

First, you need to find a place to locate this action. Create a new folder in the root project called Triggers and then add a new class file called

ShowOverlayTriggerAction.cs. Then you can adding the following code:

public class ShowOverlayTriggerAction : TriggerAction<VisualElement>

{

public bool ShowOverlay { get; set; }

protected override void Invoke(VisualElement sender)

{

sender.IsVisible = ShowOverlay;

}

}

This code doesn’t do too much right now. It will just change the IsVisible property of the control it is attached to when the value changes.

Now you need to attach it to your AddWidgetFrame control.

Using ShowOverlayTriggerAction

You can now add in the action to perform sections that you left when first adding a DataTrigger to your control. Modify your code in the FixedBoardPage.xaml file, with the changes in bold.

<DataTrigger

TargetType="Border" Binding="{Binding IsAddingWidget}" Value="True">

<DataTrigger.EnterActions>

<triggers:ShowOverlayTriggerAction ShowOverlay="True" />

</DataTrigger.EnterActions>

241