summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2191.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2191.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2191.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2191.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2191.cs
new file mode 100644
index 00000000..b334030f
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue2191.cs
@@ -0,0 +1,51 @@
+´╗┐using System;
+
+using Xamarin.Forms;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers=true)]
+ [Issue (IssueTracker.Github, 2191, "ToolBarItem not showing as disabled when CanExecute is set to false", PlatformAffected.Android)]
+ public class Issue2191 : ContentPage
+ {
+ public Issue2191 ()
+ {
+ var stackPanel = new StackLayout { VerticalOptions = LayoutOptions.End };
+ var button = new Button { Text = "Disable" };
+ var button1 = new Button { Text = "Enable" };
+ button1.Clicked+= (sender, e) => {
+ _dummyResult = true;
+ PunchSubmitCommand.ChangeCanExecute();
+ };
+ var tbItem = new ToolbarItem { Icon = "menuIcon.png" };
+ var tbItem2 = new ToolbarItem { Icon = "menuIcon.png", Text="submit" };
+ button.SetBinding (Button.CommandProperty, new Binding ("PunchSubmitCommand"));
+ tbItem.SetBinding (MenuItem.CommandProperty, new Binding ("PunchSubmitCommand"));
+ tbItem2.SetBinding (MenuItem.CommandProperty, new Binding ("PunchSubmitCommand"));
+ button.BindingContext = tbItem.BindingContext = tbItem2.BindingContext = this;
+ ToolbarItems.Add(tbItem);
+ var toolbar = new Toolbar { BackgroundColor = Color.Red };
+ toolbar.Add (tbItem2);
+ stackPanel.Children.Add (toolbar);
+ stackPanel.Children.Add (button);
+ stackPanel.Children.Add (button1);
+ Content = stackPanel;
+ }
+
+ bool _dummyResult = true;
+
+ Command _punchSubmitCommand;
+ public Command PunchSubmitCommand
+ {
+ get
+ {
+ return _punchSubmitCommand ?? (_punchSubmitCommand = new Command(() => {
+ _dummyResult = !_dummyResult;
+ PunchSubmitCommand.ChangeCanExecute();
+ },
+ () => _dummyResult));
+ }
+ }
+ }
+}