Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
BoolTemplateContentControl.cs
3
5{
9 public class BoolTemplateContentControl : ContentControl
10 {
16 public bool BoolValue
17 {
18 get => (bool)GetValue(BoolValueProperty);
19 set => SetValue(BoolValueProperty, value);
20 }
21 public static readonly DependencyProperty BoolValueProperty = DependencyProperty.Register(nameof(BoolValue), typeof(bool), typeof(BoolTemplateContentControl), new PropertyMetadata(false, OnAnyPropertyChanged));
22
26 public ControlTemplate TrueTemplate
27 {
28 get => (ControlTemplate)GetValue(TrueTemplateProperty);
29 set => SetValue(TrueTemplateProperty, value);
30 }
31 public static readonly DependencyProperty TrueTemplateProperty = DependencyProperty.Register(nameof(TrueTemplate), typeof(ControlTemplate), typeof(BoolTemplateContentControl), new PropertyMetadata(null, OnAnyPropertyChanged));
32
36 public ControlTemplate FalseTemplate
37 {
38 get => (ControlTemplate)GetValue(FalseTemplateProperty);
39 set => SetValue(FalseTemplateProperty, value);
40 }
41 public static readonly DependencyProperty FalseTemplateProperty = DependencyProperty.Register(nameof(FalseTemplate), typeof(ControlTemplate), typeof(BoolTemplateContentControl), new PropertyMetadata(null, OnAnyPropertyChanged));
42
46 private static void OnAnyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
47 {
48 var control = (BoolTemplateContentControl)d;
49 control.UpdateTemplate();
50 }
51
55 private void UpdateTemplate()
56 {
58 ApplyTemplate();
59 }
60
64 public override void OnApplyTemplate()
65 {
66 base.OnApplyTemplate();
68 }
69 }
70}
Content control that switches its template based on a boolean value.
static void OnAnyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
Callback for when any of the properties change.
ControlTemplate TrueTemplate
Dependency properties for the templates to use when BoolValue is true
override void OnApplyTemplate()
Called when the control's template is applied.
bool BoolValue
Dependency property for the boolean value that determines which template to use.
void UpdateTemplate()
Updates the template based on the current value of BoolValue
ControlTemplate FalseTemplate
Dependency properties for the templates to use when BoolValue is false