问题描述
- wpf中textBox绑定list<string>显示
-
代码如下: List<string> list = new List<string>() { "tim", "tom", "mom" }; txb1.SetBinding(TextBox.TextProperty, new Binding("/") { Source = list }); txb2.SetBinding(TextBox.TextProperty, new Binding("/") { Source = list }); txb3.SetBinding(TextBox.TextProperty, new Binding("/") { Source = list }); 如何让textbox通过绑定显示变成 ![图片说明](http://img.ask.csdn.net/upload/201512/28/1451289360_148951.png)这个样子,求教!
解决方案
txb1.SetBinding(TextBox.TextProperty, new Binding("/") { Source = list[0] });
txb2.SetBinding(TextBox.TextProperty, new Binding("/") { Source = list[1] });
txb3.SetBinding(TextBox.TextProperty, new Binding("/") { Source = list[2] });
时间: 2024-09-13 01:58:30