Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SelectLanguagePopup.xaml.cs
1using System;
2using System.Threading.Tasks;
3using CommunityToolkit.Mvvm.Messaging;
4using Microsoft.Maui.ApplicationModel;
5using Microsoft.Maui.Controls;
6using Microsoft.Maui.Devices;
8
10{
11 public partial class SelectLanguagePopup : BasePopup
12 {
13
14 public SelectLanguagePopup()
15 {
16 this.InitializeComponent();
17 this.BindingContext = new SelectLanguagePopupViewModel();
18
19
20 WeakReferenceMessenger.Default.Register<ScrollToLanguageMessage>(this, (r, m) =>
21 {
22 foreach (var element in this.LanguagesContainer.Children)
23 {
24 if (element is not VisualElement { BindingContext: ObservableLanguage lang })
25 continue;
26
27 if (lang.Language.Name != m.Value)
28 continue;
29
30 MainThread.BeginInvokeOnMainThread(async () =>
31 {
32 try
33 {
34 await this.InnerScrollView.ScrollToAsync(element as Element, ScrollToPosition.MakeVisible, true);
35 }
36 catch { /* ignore */ }
37 });
38
39 break;
40 }
41 });
42 }
43 public override Task OnDisappearingAsync()
44 {
45 WeakReferenceMessenger.Default.Unregister<ScrollToLanguageMessage>(this);
46 return base.OnDisappearingAsync();
47 }
48 }
49}
Compatibility wrapper so old Mopups based popups work using the new popup infrastructure.
Definition: BasePopup.cs:10
override Task OnDisappearingAsync()
Method called when view is disappearing from the screen.