您的位置:首页 > 其它

SilverLight学习笔记--泛型数据绑定

2008-12-09 17:02 489 查看
泛型数据绑定

数组绑定

首先拖放一个ComboBox: <ComboBox x:Name="QYLX" Width="170"></ComboBox>

定义数组: int[] myIntArray = new int[5] { 1, 2, 3, 4, 5 };

Page代码绑定:

QYLX.ItemsSource = myIntArray;

List<T>)类绑定

List<string> ListLX=new List<string>();

ListLX.Add("一般纳税人");

ListLX.Add("小规模纳税人");

QYLX.ItemsSource = ListLX;

QYLX.SelectedIndex = 1;

Dictionary<(Of <(TKey, TValue>)>) 类绑定

Dictionary<string, string> openWith = new Dictionary<string, string>();

openWith.Add("txt", "notepad.exe");

openWith.Add("bmp", "paint.exe");

openWith.Add("dib", "paint.exe");

openWith.Add("rtf", "wordpad.exe");

QYLX.ItemsSource = openWith.Values;

QYLX.SelectedIndex = 1;

Queue<(Of <(T>)>)

Queue<string> numbers = new Queue<string>();

numbers.Enqueue("one");

numbers.Enqueue("two");

numbers.Enqueue("three");

numbers.Enqueue("four");

numbers.Enqueue("five");

QYLX.ItemsSource = numbers;

QYLX.SelectedIndex = 1;

Stack<(Of <(T>)>)

Stack<string> numbers = new Stack<string>();

numbers.Push("one");

numbers.Push("two");

numbers.Push("three");

numbers.Push("four");

numbers.Push("five");

QYLX.ItemsSource = numbers;

QYLX.SelectedIndex = 1;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐