hey*_*Now 2 wpf binding observablecollection wpf-controls
我有一个Movie带有a 的类Dim _characters = New ObservableCollection(of String)
Characters是要获取和设置的关联属性
如何使用Binding将字符显示在listBox中?
到目前为止,我有以下,这是行不通的,因为我不知道该放什么代替ToString.
<ListBox Name="cList" ItemsSource="{Binding Characters}">
<ItemsControl >
<ItemsControl.ItemTemplate >
<DataTemplate >
<TextBox Text="{Binding ToString}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
我希望它们是可编辑的,因此是一个文本框.
我试图绑定Characters到TextBox直接,甚至没有工作.
编辑:在代码中,我parentGrid1.DataContext = me.movies在那里
父电网持有的电影.
对于那些正在经历异常的人
...绑定需要路径或xpath ...
您可以通过以下方式直接绑定对象:
<Label Content="{Binding .}" />
Run Code Online (Sandbox Code Playgroud)
将TextBox绑定更改为以下内容.我认为它应该工作:
<TextBox Text="{Binding}"/>
Run Code Online (Sandbox Code Playgroud)
这会加载项本身而不是属性或方法输出.由于该项是字符串,因此它应绑定到字符串值.
| 归档时间: |
|
| 查看次数: |
10397 次 |
| 最近记录: |