forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue32136.cs
More file actions
76 lines (69 loc) · 2.3 KB
/
Copy pathIssue32136.cs
File metadata and controls
76 lines (69 loc) · 2.3 KB
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
namespace Maui.Controls.Sample.Issues;
[Issue(IssueTracker.Github, 32136, "CarouselView CurrentItem Not Updating with Vertical LinearItemsLayout", PlatformAffected.iOS)]
public class Issue32136 : ContentPage
{
public Issue32136()
{
CarouselView2 carouselView = new CarouselView2
{
HeightRequest = 400,
Loop = false,
BackgroundColor = Colors.LightGray,
AutomationId = "TestCarouselView",
ItemsLayout = new LinearItemsLayout(ItemsLayoutOrientation.Vertical),
ItemTemplate = new DataTemplate(() =>
{
Label label = new Label
{
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.Center
};
label.SetBinding(Label.TextProperty, ".");
return new Grid
{
Children = { label }
};
}),
ItemsSource = new string[]
{
"Baboon",
"Capuchin Monkey",
"Blue Monkey",
"Squirrel Monkey",
"Golden Lion Tamarin"
}
};
Label currentItemLabel = new Label();
currentItemLabel.AutomationId = "CurrentItemLabel";
currentItemLabel.Text = "CurrentItem = Baboon";
Button button = new Button
{
Text = "Next Item",
AutomationId = "ScrollButton"
};
button.Clicked += (s, e) =>
{
currentItemLabel.Text = "Button was clicked";
carouselView.ScrollTo(carouselView.Position + 1, position: ScrollToPosition.Center, animate: true);
};
carouselView.CurrentItemChanged += (s, e) =>
{
currentItemLabel.Text = $"CurrentItem = {e.CurrentItem}";
};
Grid grid = new Grid
{
Padding = 25,
RowSpacing = 10,
RowDefinitions =
{
new RowDefinition(GridLength.Auto),
new RowDefinition(GridLength.Auto),
new RowDefinition(GridLength.Auto)
}
};
grid.Add(carouselView);
grid.Add(currentItemLabel, row: 1);
grid.Add(button, row: 2);
Content = grid;
}
}