-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
StateTrigger.cs
38 lines (34 loc) · 1.08 KB
/
StateTrigger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#nullable disable
namespace Microsoft.Maui.Controls
{
/// <include file="../../docs/Microsoft.Maui.Controls/StateTrigger.xml" path="Type[@FullName='Microsoft.Maui.Controls.StateTrigger']/Docs/*" />
public sealed class StateTrigger : StateTriggerBase
{
/// <include file="../../docs/Microsoft.Maui.Controls/StateTrigger.xml" path="//Member[@MemberName='IsActive']/Docs/*" />
public new bool IsActive
{
get => (bool)GetValue(IsActiveProperty);
set => SetValue(IsActiveProperty, value);
}
/// <summary>Bindable property for <see cref="IsActive"/>.</summary>
public static readonly BindableProperty IsActiveProperty =
BindableProperty.Create(nameof(IsActive), typeof(bool), typeof(StateTrigger), default(bool),
propertyChanged: OnIsActiveChanged);
static void OnIsActiveChanged(BindableObject bindable, object oldvalue, object newvalue)
{
if (newvalue is bool b)
{
((StateTrigger)bindable).UpdateState();
}
}
protected override void OnAttached()
{
base.OnAttached();
UpdateState();
}
void UpdateState()
{
SetActive(IsActive);
}
}
}