Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UnfocusOnClickedBehavior.cs
1using System.ComponentModel;
3
5{
9 public class UnfocusOnClickedBehavior : Behavior<View>
10 {
14 [TypeConverter(typeof(ReferenceTypeConverter))]
15 public View? UnfocusControl { get; set; }
16
18 protected override void OnAttachedTo(View View)
19 {
20 if (View is Controls.ImageButton ImageButton)
21 ImageButton.Clicked += this.Button_Clicked;
22 else if (View is Button Button)
23 Button.Clicked += this.Button_Clicked;
24
25 base.OnAttachedTo(View);
26 }
27
29 protected override void OnDetachingFrom(View View)
30 {
31 if (View is Controls.ImageButton ImageButton)
32 ImageButton.Clicked -= this.Button_Clicked;
33 else if (View is Button Button)
34 Button.Clicked -= this.Button_Clicked;
35
36 base.OnDetachingFrom(View);
37 }
38
39 private void Button_Clicked(object? Sender, EventArgs e)
40 {
42 }
43
48 public static void Unfocus(View? Element)
49 {
50 ServiceRef.PlatformSpecific.HideKeyboard();
51
52 if (Element is not null && Element.IsVisible)
53 Element.Unfocus();
54 }
55 }
56}
Base class that references services in the app.
Definition: ServiceRef.cs:31
static void Unfocus(View? Element)
Sets focus on an element.