Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
StateProperties.cs
2{
9 public static class StateProperties
10 {
14 public static readonly BindableProperty StateProperty =
15 BindableProperty.CreateAttached(
16 propertyName: "State",
17 returnType: typeof(object),
18 declaringType: typeof(StateProperties),
19 defaultValue: null,
20 propertyChanged: OnStateChanged);
21
25 public static object? GetState(BindableObject View)
26 => View.GetValue(StateProperty);
27
32 public static void SetState(BindableObject View, object? Value)
33 => View.SetValue(StateProperty, Value);
34
35 static void OnStateChanged(BindableObject Bindable, object? OldValue, object? NewValue)
36 {
37 Console.WriteLine($"New state for {Bindable.GetType().Name} : Value: {NewValue}");
38 // If you want controls to transition VisualState, uncomment below:
39 // if (bindable is VisualElement ve && newValue is not null)
40 // VisualStateManager.GoToState(ve, newValue.ToString());
41
42 // Else, this attached property solely reflects state for DataTriggers.
43 }
44 }
45}
Provides an attached State property for any BindableObject, usable in DataTriggers in place of Visual...
static ? object GetState(BindableObject View)
Gets the State attached property.
static readonly BindableProperty StateProperty
Attached State property (e.g. string or enum).
static void SetState(BindableObject View, object? Value)
Sets the State attached property. When set, optionally you could call VisualStateManager....