-
Notifications
You must be signed in to change notification settings - Fork 338
/
IsListNotNullOrEmptyConverterPage.xaml
50 lines (42 loc) · 2.25 KB
/
IsListNotNullOrEmptyConverterPage.xaml
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
<pages:BasePage
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mct="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
xmlns:pages="clr-namespace:CommunityToolkit.Maui.Sample.Pages"
xmlns:vm="clr-namespace:CommunityToolkit.Maui.Sample.ViewModels.Converters"
x:Class="CommunityToolkit.Maui.Sample.Pages.Converters.IsListNotNullOrEmptyConverterPage"
x:DataType="vm:IsListNotNullOrEmptyConverterViewModel"
x:TypeArguments="vm:IsListNotNullOrEmptyConverterViewModel">
<pages:BasePage.Resources>
<ResourceDictionary>
<mct:IsListNotNullOrEmptyConverter x:Key="IsListNotNullOrEmptyConverter" />
</ResourceDictionary>
</pages:BasePage.Resources>
<pages:BasePage.Content>
<VerticalStackLayout
Padding="10,10"
Spacing="10">
<Label
Text="The IsListNotNullOrEmptyConverter is a converter that allows users to convert an incoming binding that implements IEnumerable to a bool value. This value represents if the incoming binding value is not null or an empty list."
TextColor="{StaticResource NormalLabelTextColor}" />
<BoxView
HeightRequest="20"
BackgroundColor="Transparent"/>
<Label
Text="This label should be true if the collection item is not null or not empty"
TextColor="{StaticResource NormalLabelTextColor}" />
<Label
Text="{Binding StringItemSource, Converter={StaticResource IsListNotNullOrEmptyConverter}}"
FontAttributes="Bold"
TextColor="Red" />
<Button Text="Clear List" Command="{Binding ClearCollectionCommand}" />
<CollectionView ItemsSource="{Binding StringItemSource}">
<CollectionView.ItemTemplate>
<DataTemplate x:DataType="x:String">
<Label Text="{Binding .}" Margin="10" TextColor="{StaticResource NormalLabelTextColor}" />
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</VerticalStackLayout>
</pages:BasePage.Content>
</pages:BasePage>