-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainPage.cs
79 lines (67 loc) · 2.21 KB
/
MainPage.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using MauiReactor;
using SfIntApp.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SfIntApp.Pages;
record PickerItem(string Name);
class MainPageState
{
public int Counter { get; set; }
public bool IsPopupOpen { get; set; }
public List<PickerItem> Items { get; set; } = Enumerable.Range(1, 10).Select(_ => new PickerItem($"Item {_}")).ToList();
public PickerItem SelectedItem { get; set; }
}
class MainPage : Component<MainPageState>
{
public override VisualNode Render()
{
return new ContentPage
{
new ScrollView
{
new VStack
{
new SfTextInputLayout
{
new Entry()
}
.Hint("Name"),
new SfTextInputLayout
{
new Entry()
}
.Hint("Password")
.EnablePasswordVisibilityToggle(true)
,
new Button().Text("Open Popup").OnClicked(()=>SetState(s => s.IsPopupOpen = true)),
new SfPopup()
.Content(()=>
new CollectionView()
.ItemsSource(State.Items, item => new Label(item.Name))
.OnSelected<CollectionView, PickerItem>(OnItemSelected)
.SelectionMode(MauiControls.SelectionMode.Single)
.Margin(10)
)
.AutoSizeMode(Syncfusion.Maui.Popup.PopupAutoSizeMode.None)
.IsOpen(State.IsPopupOpen)
.OnClosed(()=>SetState(s => s.IsPopupOpen = false, false)),
new Label($"SelectedItem: {State.SelectedItem?.Name}")
}
.VCenter()
.Spacing(25)
.Padding(30, 0)
}
};
}
private void OnItemSelected(PickerItem item)
{
SetState(s =>
{
s.SelectedItem = item;
s.IsPopupOpen = false;
});
}
}