-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathCardsSampleView.cs
73 lines (59 loc) · 1.94 KB
/
CardsSampleView.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
using PanCardView;
using PanCardViewSample.CardsFactory;
using PanCardViewSample.ViewModels;
using Xamarin.Forms;
namespace PanCardViewSample.Views
{
public class CardsSampleView : ContentPage
{
public CardsSampleView()
{
var cardsView = new CardsView
{
ItemTemplate = new DataTemplate(() => new DefaultCardItemView()),
BackgroundColor = Color.Black.MultiplyAlpha(.9)
};
AbsoluteLayout.SetLayoutFlags(cardsView, AbsoluteLayoutFlags.All);
AbsoluteLayout.SetLayoutBounds(cardsView, new Rectangle(0, 0, 1, 1));
var prevItem = new ToolbarItem
{
Text = "**Prev**",
IconImageSource = "prev.png",
CommandParameter = false
};
prevItem.SetBinding(MenuItem.CommandProperty, nameof(CardsSampleViewModel.PanPositionChangedCommand));
var nextItem = new ToolbarItem
{
Text = "**Next**",
IconImageSource = "next.png",
CommandParameter = true
};
nextItem.SetBinding(MenuItem.CommandProperty, nameof(CardsSampleViewModel.PanPositionChangedCommand));
ToolbarItems.Add(prevItem);
ToolbarItems.Add(nextItem);
cardsView.SetBinding(CardsView.ItemsSourceProperty, nameof(CardsSampleViewModel.Items));
cardsView.SetBinding(CardsView.SelectedIndexProperty, nameof(CardsSampleViewModel.CurrentIndex));
Title = "Cards View";
var removeButton = new Button
{
Text = "Remove current",
FontAttributes = FontAttributes.Bold,
TextColor = Color.Black,
BackgroundColor = Color.Yellow.MultiplyAlpha(.7),
Margin = new Thickness(0, 0, 0, 10)
};
removeButton.SetBinding(Button.CommandProperty, nameof(CardsSampleViewModel.RemoveCurrentItemCommand));
AbsoluteLayout.SetLayoutFlags(removeButton, AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(removeButton, new Rectangle(.5, 1, 150, 40));
Content = new AbsoluteLayout()
{
Children =
{
cardsView,
removeButton
}
};
BindingContext = new CardsSampleViewModel();
}
}
}