-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml
48 lines (42 loc) · 2.47 KB
/
MainPage.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
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:CustomCollectionView"
x:Class="CustomCollectionView.MainPage"
x:DataType="local:MainViewModel"
>
<Grid Margin="0, 20" RowDefinitions="auto, *, auto">
<Button Margin="20" Text="Add" Command="{Binding AddNewItemCommand}"/>
<local:CustomCollectionView Grid.Row="1" SelectedItem="{Binding SelectedItem, Mode=TwoWay}" ItemsSource="{Binding Items}" >
<local:CustomCollectionView.ItemTemplate>
<DataTemplate x:DataType="local:ItemViewModel">
<Grid Padding="16">
<VisualStateManager.VisualStateGroups>
<VisualStateGroupList>
<VisualStateGroup x:Name="CustomCollectionViewStates">
<VisualState x:Name="_Normal">
<VisualState.Setters>
<Setter Property="Background" Value="Transparent"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="_Selected">
<VisualState.Setters>
<Setter Property="Background" Value="Pink"/>
</VisualState.Setters>
</VisualState>
<VisualState x:Name="_Hovered">
<VisualState.Setters>
<Setter Property="Background" Value="Yellow"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</VisualStateManager.VisualStateGroups>
<Label Text="{Binding Title}"/>
</Grid>
</DataTemplate>
</local:CustomCollectionView.ItemTemplate>
</local:CustomCollectionView>
<Label HorizontalOptions="Center" Grid.Row="2" Text="{Binding SelectedItem.Title, StringFormat='{} Selected item: {0}'}"/>
</Grid>
</ContentPage>