Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一组电话号码:
phonenumbers.add(new phonenumber("mobile", "1234")); phonenumbers.add(new phonenumber("home", "5678"));
如果我有 2 个文本框,txtMobile 和 txtHome,如何将每个电话号码绑定到各个文本框?
谢谢!
您可以在 WPF 中索引您的绑定。尝试这个:
<TextBox Text="{Binding phonenumbers[0]}" /> <TextBox Text="{Binding phonenumbers[1]}" />
您可以绑定到索引。
Text={Binding phonenumbers[0]}
否则,为电话号码创建单独的属性并绑定到它们。