-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpicker.js
58 lines (53 loc) · 2.06 KB
/
picker.js
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
// Picker page
//
exports.View =
{
title: "Picker",
elements:
[
{ control: "picker", width: 150, margin: { bottom: 10 }, binding: {
items: "colors", itemContent: "Color: {name}", selection: "selectedColor", selectionItem: "value",
onSelectionChange: { command: "clicked", control: "Picker", colorName: "{name}" }
}
},
{ control: "border", border: "White", borderThickness: "5", contents: [
{ control: "rectangle", width: "100", height: "100", color: "{selectedColor}" },
] },
{ control: "listview", select: "Single", height: 250, width: 300, binding: {
items: "colors", itemContent: "{name}", selection: "selectedColor", selectionItem: "value",
onSelectionChange: { command: "clicked", control: "ListBox", colorName: "{name}" }
}
},
{ control: "listview", select: "Single", height: 300, width: 300,
binding: {
items: "colors", selection: "selectedColor", selectionItem: "value",
onSelectionChange: { command: "clicked", control: "ListView", colorName: "{name}" }
},
itemTemplate: [
{ control: "stackpanel", orientation: "Horizontal", width: "*", padding: 5, contents: [
{ control: "text", width: 100, value: "{name}" },
{ control: "rectangle", height: 25, width: 100, color: "{value}" },
] }
]
},
]
}
exports.InitializeViewModel = function(context, session)
{
var viewModel =
{
colors:
[
{ name: "Red", color: "red", value: "#ff0000" }, { name: "Green", color: "green", value: "#00ff00" }, { name: "Blue", color: "blue", value: "#0000ff" },
],
selectedColor: "#00ff00",
}
return viewModel;
}
exports.Commands =
{
clicked: function(context, session, viewModel, params)
{
return Synchro.showMessage(context, { message: params.control + " selection changed, new color: " + params.colorName });
},
}