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;
数组绑定
首先拖放一个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;
相关文章推荐
- WPF and Silverlight 学习笔记(二十一):数据绑定值的自定义转换
- WPF and Silverlight 学习笔记(二十):WPF数据绑定概述
- WPF and Silverlight 学习笔记(二十二):使用代码实现绑定、绑定数据的验证
- SilverLight学习笔记--Silverlight中INotifyPropertyChanged 接口在数据绑定中的使用
- WPF and Silverlight 学习笔记(二十一):数据绑定值的自定义转换
- WPF and Silverlight 学习笔记(二十五):使用CollectionView实现对绑定数据的排序、筛选、分组
- SilverLight学习笔记--关于使用IValueConvert对绑定数据的格式化操作
- [转]WPF and Silverlight 学习笔记(二十五):使用CollectionView实现对绑定数据的排序、筛选、分组
- WPF and Silverlight 学习笔记(二十二):使用代码实现绑定、绑定数据的验证
- SilverLight 学习笔记--Silverlight中INotifyPropertyChanged 接口在数据绑定中的使用
- SilverLight学习笔记--Silverlight之数据绑定初探
- WPF and Silverlight 学习笔记(二十):WPF数据绑定概述
- silverlight 学习笔记 (三): silverlight中的数据绑定
- Silverlight学习笔记第一季(2)Listbox横向绑定数据
- SilverLight学习笔记--对象数据绑定
- SilverLight学习笔记--Silverlight之数据绑定初探
- silverlight 学习笔记 (三): silverlight中的数据绑定
- WPF and Silverlight 学习笔记(二十五):使用CollectionView实现对绑定数据的排序、筛选、分组
- WPF and Silverlight 学习笔记(二十二):使用代码实现绑定、绑定数据的验证
- SilverLight学习笔记之三数据绑定方式(上)