This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[C] Prevent enabling a Button via setting a Command
- Loading branch information
Paul DiPietro
committed
Sep 6, 2016
1 parent
11326e1
commit 2571938
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla43354.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters