blob: b334030fa63fd7932f48e4d239cfc25ff60110ff (
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
|
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));
}
}
}
}
|