summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43354.cs
blob: 6ed77b9615de1afdceb70f18c2b7dfe2eff01715 (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
using System;

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
	[Preserve(AllMembers = true)]
	[Issue(IssueTracker.Bugzilla, 43354, "Button command being set after IsEnabled enables the button", PlatformAffected.All)]
	public class Bugzilla43354 : TestContentPage
	{
		protected override void Init()
		{
			var buttonIsEnabledSetFirst = new Button
			{
				Text = "Click to display an alert",
				IsEnabled = false,
				Command = new Command(() => DisplayAlert("Test", "Message", "Cancel")),
			};

			var buttonIsEnabledSetSecond = new Button
			{
				Text = "Click to enable/disable button",
				Command = new Command(() =>
				{
					if (buttonIsEnabledSetFirst.IsEnabled)
						buttonIsEnabledSetFirst.IsEnabled = false;
					else
						buttonIsEnabledSetFirst.IsEnabled = true;
				})
			};

			var buttonSetCommandToNull = new Button
			{
				Text = "Click to set first button's command to null",
				Command = new Command(() => buttonIsEnabledSetFirst.Command = null)
			};

			Content = Content = new StackLayout
			{
				VerticalOptions = LayoutOptions.Center,
				Children =
				{
						buttonIsEnabledSetFirst,
						buttonIsEnabledSetSecond,
						buttonSetCommandToNull
				}
			};
		}
	}
}