获取ItemsControl中当前item的binding数据

时间:2023-03-08 17:19:20
获取ItemsControl中当前item的binding数据

直接用 {Binding} 就可以了,如下:

<ItemsControl ItemsSource="{Binding Path=ProcessItems}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True"></WrapPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Name="ProcessItemBorder" Padding="" Margin="" BorderThickness="" BorderBrush="Black"
PreviewMouseMove="ProcessItemBorder_OnPreviewMouseMove"
Tag="{Binding}">
<TextBlock Text="{Binding Path=ItemName}"></TextBlock>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>