-
-
Notifications
You must be signed in to change notification settings - Fork 193
/
Copy pathConditionView.cs
32 lines (27 loc) · 1.07 KB
/
ConditionView.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
namespace MauiConditionView;
public class ConditionView : ContentView
{
public static readonly BindableProperty FalseProperty = BindableProperty.Create(nameof(False), typeof(View), typeof(ConditionView), default(View));
public static readonly BindableProperty TrueProperty = BindableProperty.Create(nameof(True), typeof(View), typeof(ConditionView), default(View));
public static readonly BindableProperty IfProperty = BindableProperty.Create(nameof(If), typeof(bool), typeof(ConditionView), default(bool), propertyChanged: ConditionChanged);
private static void ConditionChanged(BindableObject bindable, object oldvalue, object newvalue)
{
var conditionView = (ConditionView)bindable;
conditionView.Content = (bool)newvalue ? conditionView.True : conditionView.False;
}
public bool If
{
get => (bool)GetValue(IfProperty);
set => SetValue(IfProperty, value);
}
public View True
{
get => (View)GetValue(TrueProperty);
set => SetValue(TrueProperty, value);
}
public View False
{
get => (View)GetValue(FalseProperty);
set => SetValue(FalseProperty, value);
}
}