She*_*ock 6 c# data-binding wpf xaml itemssource
我有一个具有一个依赖项属性的用户控件.在我的窗口中,我有一个对象列表,我正在创建一个由我的用户控件组成的统一网格.我将ItemsSource设置为我的对象列表,但我需要将每个相应的对象传递给用户控件.请参阅下面的代码 - 我需要将Participant对象传递给LadderControl.
<ItemsControl Grid.Row="2" Name="Participants" ItemsSource="{Binding Path=MyEvent.Participants}">
// more code here, irrelevant
<ItemsControl.ItemTemplate>
<DataTemplate>
<ladder:LadderControl Participant="CURRENT_ITEM_IN_PARTICIPANTS_LIST"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
有没有办法可以做到这一点?我应该考虑使用不同的模式吗?
谢谢
只需执行以下操作,因为参与者是每个项目的上下文
<ladder:LadderControl Participant="{Binding}"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2802 次 |
| 最近记录: |