1

假设我有一组电话号码:

phonenumbers.add(new phonenumber("mobile", "1234"));
phonenumbers.add(new phonenumber("home", "5678"));

如果我有 2 个文本框,txtMobile 和 txtHome,如何将每个电话号码绑定到各个文本框?

谢谢!

4

2 回答 2

2

您可以在 WPF 中索引您的绑定。尝试这个:

<TextBox Text="{Binding phonenumbers[0]}" />
<TextBox Text="{Binding phonenumbers[1]}" />
于 2010-11-17T23:19:44.403 回答
0

您可以绑定到索引。

Text={Binding phonenumbers[0]}

否则,为电话号码创建单独的属性并绑定到它们。

于 2010-11-17T23:19:54.670 回答