-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
SwipeCarouselViewGallery.xaml
109 lines (104 loc) · 4.9 KB
/
SwipeCarouselViewGallery.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?xml version="1.0" encoding="UTF-8" ?>
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Xamarin.Forms.Controls.GalleryPages.SwipeViewGalleries.SwipeCarouselViewGallery"
Title="Swipe CarouselView">
<ContentPage.Resources>
<ResourceDictionary>
<Style x:Key="TitleStyle" TargetType="Label">
<Setter Property="FontSize" Value="14" />
<Setter Property="TextColor" Value="Black" />
<Setter Property="Margin" Value="6, 0, 6, 6" />
</Style>
<Style x:Key="DateStyle" TargetType="Label">
<Setter Property="TextColor" Value="DarkGray" />
<Setter Property="FontSize" Value="10" />
<Setter Property="Margin" Value="6, 0, 6, 6" />
</Style>
<Style x:Key="SubTitleStyle" TargetType="Label">
<Setter Property="TextColor" Value="DarkGray" />
<Setter Property="FontSize" Value="12" />
<Setter Property="Margin" Value="6, 0" />
</Style>
<DataTemplate x:Key="MessageTemplate">
<SwipeView
HeightRequest="120">
<SwipeView.TopItems>
<SwipeItems>
<SwipeItem
Text="Favourite"
Icon="calculator.png"
BackgroundColor="Yellow"
Command="{Binding Source={x:Reference SwipeCollectionView}, Path=BindingContext.FavouriteCommand}"/>
</SwipeItems>
</SwipeView.TopItems>
<SwipeView.BottomItems>
<SwipeItems
Mode="Execute">
<SwipeItem
Text="Delete"
Icon="coffee.png"
BackgroundColor="Red"
Command="{Binding Source={x:Reference SwipeCollectionView}, Path=BindingContext.DeleteCommand}"/>
</SwipeItems>
</SwipeView.BottomItems>
<SwipeView.Content>
<Grid
BackgroundColor="White"
HeightRequest="120"
RowSpacing="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label
Grid.Column="0"
Grid.Row="0"
Text="{Binding Title}"
Style="{StaticResource TitleStyle}"/>
<Label
Grid.Column="1"
Grid.Row="0"
Text="{Binding Date}"
Style="{StaticResource DateStyle}"/>
<Label
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
Text="{Binding SubTitle}"
Style="{StaticResource SubTitleStyle}"/>
<Label
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="2"
Text="{Binding Description}"
Style="{StaticResource SubTitleStyle}"/>
</Grid>
</SwipeView.Content>
</SwipeView>
</DataTemplate>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Content>
<StackLayout>
<CarouselView
x:Name="SwipeCollectionView"
ItemsSource="{Binding Messages}"
ItemTemplate="{StaticResource MessageTemplate}"
HeightRequest="120">
<CarouselView.ItemsLayout>
<LinearItemsLayout
Orientation="Horizontal"
SnapPointsAlignment="Center"
SnapPointsType="MandatorySingle"/>
</CarouselView.ItemsLayout>
</CarouselView>
</StackLayout>
</ContentPage.Content>
</ContentPage>