Vic*_*ues 8 .net c# wpf wpf-controls
人们常常使用以下内容:
<ListBox ItemsSource="{Binding ElementName=thisControl, Path=ListIndexes}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Label Content="{Binding Path=IndexName}"/>
<Label Content="{Binding Path=IndexValue}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
但是我想使用而不是标签来控制,如下所示:
<ListBox ItemsSource="{Binding ElementName=thisControl, Path=ListIndexes}">
<ListBox.ItemTemplate>
<DataTemplate>
<local:Index Item="**{Binding}**"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Run Code Online (Sandbox Code Playgroud)
我怀疑是如何将这个Binding包含在集合中的整个项目中.
Ray*_*sen 15
这个语法是:
<local:Index Item="{Binding}"/>
Run Code Online (Sandbox Code Playgroud)
这将告诉数据绑定函数将每个ListBox项的整个datacontext绑定到Index控件中的Item属性
| 归档时间: |
|
| 查看次数: |
5110 次 |
| 最近记录: |