forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToolbarItems.cs
61 lines (50 loc) · 1.27 KB
/
ToolbarItems.cs
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
using System;
using Xamarin.Forms;
namespace Xamarin.Forms.Controls
{
public class ToolbarItems : ContentPage
{
bool _isEnable = false;
public ToolbarItems()
{
var label = new Label { Text = "Hello ContentPage", AutomationId = "label_id" };
var command = new Command((obj) =>
{
label.Text = "tb4";
}, (obj) => _isEnable);
var tb1 = new ToolbarItem("tb1", "menuIcon.png", () =>
{
label.Text = "tb1";
}, ToolbarItemOrder.Primary);
tb1.IsEnabled = _isEnable;
tb1.AutomationId = "toolbaritem_primary";
var tb2 = new ToolbarItem("tb2", null, () =>
{
label.Text = "tb2";
}, ToolbarItemOrder.Primary);
tb2.AutomationId = "toolbaritem_primary2";
var tb3 = new ToolbarItem("tb3", "bank.png", () =>
{
label.Text = "tb3";
_isEnable = !_isEnable;
command.ChangeCanExecute();
}, ToolbarItemOrder.Secondary);
tb3.AutomationId = "toolbaritem_secondary";
var tb4 = new ToolbarItem();
tb4.Text = "tb4";
tb4.Order = ToolbarItemOrder.Secondary;
tb4.Command = command;
tb4.AutomationId = "toolbaritem_secondary2";
ToolbarItems.Add(tb1);
ToolbarItems.Add(tb2);
ToolbarItems.Add(tb3);
ToolbarItems.Add(tb4);
Content = new StackLayout
{
Children = {
label
}
};
}
}
}