-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue10672.xaml.cs
77 lines (66 loc) · 1.72 KB
/
Issue10672.xaml.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
74
75
76
77
using System;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Xamarin.Forms.Xaml;
using Xamarin.Forms.Internals;
using Xamarin.Forms.CustomAttributes;
#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls
{
#if UITEST
[Category(UITestCategories.CarouselView)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 10672, "[Bug] Setting CarouselView.IsScrollAnimated To False Throws Exception On UWP When Resizing The Window", PlatformAffected.UWP)]
public partial class Issue10672 : TestContentPage
{
public Issue10672()
{
#if APP
InitializeComponent();
#endif
}
public ObservableCollection<CarouselItemViewModel> Items { get; } = new ObservableCollection<CarouselItemViewModel>();
protected override void Init()
{
for (int i = 0; i < 5; i++)
Items.Add(new CarouselItemViewModel());
BindingContext = this;
}
}
[Preserve(AllMembers = true)]
public class CarouselItemViewModel : BindableObject
{
static string RandomImage(int w = 1000, int h = 1000) => $"https://picsum.photos/{w}/{h}?{Guid.NewGuid()}";
public ObservableCollection<string> Images { get; } = new ObservableCollection<string>();
int _position;
public int Position
{
get { return _position; }
set
{
_position = value;
OnPropertyChanged();
}
}
public CarouselItemViewModel()
{
Images.Add(RandomImage());
Images.Add(RandomImage());
Images.Add(RandomImage());
}
public ICommand Next => new Command(() =>
{
Position = (Position + 1) % Images.Count;
});
public ICommand Prev => new Command(() =>
{
var count = Images.Count;
Position = (count + Position - 1) % count;
});
}
}