summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43214.cs
blob: 358c3a6c904e4996d5019f073f64e421bf717e95 (plain)
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
using System.Linq;
using System.Threading.Tasks;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif

namespace Xamarin.Forms.Controls
{
#if UITEST
	[Category(UITestCategories.ListView)]
#endif

	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 43214, "Setting Listview.IsRefreshing to false does not work on second \"pull\"")]
	public class Bugzilla43214 : TestContentPage
	{
		public class MyViewModel : ViewModel
		{
			bool _isBusy;

			public bool IsBusy
			{
				get { return _isBusy; }
				set
				{
					_isBusy = value;
					OnPropertyChanged();
				}
			}
		}

		protected override void Init()
		{
			var vm = new MyViewModel();

			var label = new Label { Text = "Pull list to refresh once, then pull to refresh again. If the indicator does not disappear, this test has failed." };
			var listview = new ListView
			{
				ItemsSource = Enumerable.Range(0, 20),
				IsPullToRefreshEnabled = true,
				RefreshCommand = new Command(async () =>
				{
					vm.IsBusy = true;
					await Task.Delay(1000);
					vm.IsBusy = false;
				})
			};

			listview.SetBinding(ListView.IsRefreshingProperty, nameof(MyViewModel.IsBusy));

			var stacklayout = new StackLayout { Children = { label, listview }, BindingContext = vm };

			Content = stacklayout;
		}
	}
}