@cpp:Private var counter : int = 0;

prop ItemsToBind : observe MyTextItem^[] = {} {const, not observe}

@cpp:Private func ToText_1to9(i : int) : string { switch (i) { case 1: { return "one"; } case 2: { return "two"; } case 3: { return "three"; } case 4: { return "four"; } case 5: { return "five"; } case 6: { return "six"; } case 7: { return "seven"; } case 8: { return "eight"; } case 9: { return "nine"; } } raise "ToText_1to9: Number out of range."; }

@cpp:Private func ToText_11to19(i : int) : string { switch (i) { case 1: { return "eleven"; } case 2: { return "twelve"; } case 3: { return "thirteen"; } case 4: { return "fourteen"; } case 5: { return "fifteen"; } case 6: { return "sixteen"; } case 7: { return "seventeen"; } case 8: { return "eightteen"; } case 9: { return "nineteen"; } } raise "ToText_11to19: Number out of range."; }

@cpp:Private func NumberToText_1To99(i : int) : string { switch (i / 10) { case 0: { return ToText_1to9(i % 10); } case 1: { return i == 10 ? "ten" : ToText_11to19(i % 10); } case 2: { return i % 10 == 0 ? "twenty" : "twenty-" & ToText_1to9(i % 10); } case 3: { return i % 10 == 0 ? "thirty" : "thirty-" & ToText_1to9(i % 10); } case 4: { return i % 10 == 0 ? "fourty" : "fourty-" & ToText_1to9(i % 10); } case 5: { return i % 10 == 0 ? "fifty" : "fifty-" & ToText_1to9(i % 10); } case 6: { return i % 10 == 0 ? "sixty" : "sixty-" & ToText_1to9(i % 10); } case 7: { return i % 10 == 0 ? "seventy" : "seventy-" & ToText_1to9(i % 10); } case 8: { return i % 10 == 0 ? "eighty" : "eighty-" & ToText_1to9(i % 10); } case 9: { return i % 10 == 0 ? "ninety" : "ninety-" & ToText_1to9(i % 10); } } raise "NumberToText_1To99: Number out of range."; }

@cpp:Private func NumberToText_0to999(i : int) : string { if (i < 100) { return NumberToText_1To99(i); } return ToText_1to9(i / 100) & " hundred" & (i % 100 == 0 ? "" : " and " & NumberToText_1To99(i % 100)); }

@cpp:Private func NumberToText(i : int) : string { if (i == 0) { return "zero"; } if (i < 1000) { return NumberToText_0to999(i); } return "Number too large: " & i; }

A

{ for (i in range [0, 9]) { var textItem = new demo::MyTextItem^(); textItem.Name = self.NumberToText(self.counter + i); self.ItemsToBind.Add(textItem); }

self.counter = self.counter + 10; }

O

{ var i = 0; while (i < self.ItemsToBind.Count) { self.ItemsToBind.RemoveAt(i); i = i + 1; } }

E

{ var i = 1; while (i < self.ItemsToBind.Count) { self.ItemsToBind.RemoveAt(i); i = i + 1; } }

C

{ self.ItemsToBind.Clear(); }

R

{ self.counter = 0; }
prop ItemsToBind : observe MyTextItem^[] = {} {const, not observe} prop ContentComposition: GuiGraphicsComposition* = null {const, not observe}
{ SetItemsToBind(controller.ItemsToBind); SetContentComposition(content); }

<_>composeType:Percentage percentage:1.0
<_>composeType:Percentage percentage:1.0 <_>composeType:MinSize