Skip to content

Commit 6d39457

Browse files
committed
feat(ListState): Add ListState and ListView code from tutorial
1 parent d0d8b27 commit 6d39457

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/DevTKSS.Uno.XamlNavigationApp-1/Presentation/DashboardModel.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,20 @@ public DashboardModel()
55
{
66

77
}
8+
private async ValueTask<IImmutableList<string>> GetMembers(CancellationToken ct) => _listMembers;
9+
10+
private readonly IImmutableList<string> _listMembers = ImmutableList.Create(
11+
[
12+
"Hans",
13+
"Lisa",
14+
"Anke",
15+
"Tom"
16+
]);
17+
818
public IState<string> DashboardTitle => State<string>.Value(this, () => "Hallo vom Dashboard");
19+
20+
public IListState<string> DashboardList => ListState.Async(this,GetMembers)
21+
.Selection(SelectedMember);
22+
23+
public IState<string> SelectedMember => State<string>.Empty(this);
924
}

src/DevTKSS.Uno.XamlNavigationApp-1/Presentation/DashboardPage.xaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,29 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
xmlns:utu="using:Uno.Toolkit.UI"
9+
xmlns:mvux="using:Uno.Extensions.Reactive.UI"
910
mc:Ignorable="d"
1011
Background="{ThemeResource BackgroundBrush}">
1112

12-
<Grid utu:SafeArea.Insets="VisibleBounds">
13+
<Grid RowSpacing="10" Padding="15"
14+
utu:SafeArea.Insets="VisibleBounds">
15+
<Grid.RowDefinitions>
16+
<RowDefinition Height="Auto" />
17+
<RowDefinition Height="Auto" />
18+
<RowDefinition Height="*" />
19+
</Grid.RowDefinitions>
1320
<TextBlock Text="{Binding DashboardTitle}"
1421
HorizontalTextAlignment="Center"
1522
VerticalAlignment="Center" />
23+
24+
<TextBlock Grid.Row="1"
25+
HorizontalAlignment="Center"
26+
TextAlignment="Center">
27+
<Run Text="Selected Name:" /> <Run Text="{Binding SelectedMember}" />
28+
</TextBlock>
29+
30+
<ListView Grid.Row="2"
31+
ItemsSource="{Binding DashboardList}" />
32+
1633
</Grid>
17-
</Page>
34+
</Page>

0 commit comments

Comments
 (0)