xaml中的一些使用方法
1. 构造对象
public class Food { private string _name; private Int32 _calories; public Food(string name, Int32 calories) { _name=name; _calories=calories; } } <my:Food> <x:Arguments> <x:String>Apple</x:String> <x:Int32>150</x:Int32> </x:Arguments> </my:Food>
public Food TryLookupFood(string name) { switch (name) { case "Apple": return new Food("Apple",150); case "Chocolate": return new Food("Chocolate",200); case "Cheese": return new Food("Cheese", 450); default: {return new Food(name,0); } } <my:Food x:FactoryMethod="TryLookupFood"> <x:Arguments> <x:String>Apple</x:String> </x:Arguments> </my:Food>
2. 定义数组
<x:Array Type="sys:String"> <sys:String>String1</sys:String> <sys:String>String2</sys:String> <sys:String>String3</sys:String> </x:Array>

浙公网安备 33010602011771号