【发布时间】:2011-10-06 14:05:28
【问题描述】:
我需要将一些 ComboBoxes 绑定到一个 ObservableCollection。
我有这个ListView。
<ListView x:Name="lwCoefTables" Grid.Column="1" ItemsSource="{Binding Source={StaticResource CollectionCoefContainers}}">
<ListView.ItemTemplate>
<DataTemplate>
<ComboBox x:Name="cmbCoefTableTypes" ItemsSource="{Binding Source={StaticResource CollectionCoefLinksTable}}"
SelectedItem="{Binding CoefLinksTableType, Mode=TwoWay}" Grid.Column="1" VerticalAlignment="Center"
HorizontalAlignment="Left" Width="180" DisplayMemberPath="Name">
</ComboBox>
</DataTemplate>
</ListView.ItemTemplate>
我想将我的集合绑定到所有 ComboBox 并为每个 ComboBox 保存选定的项目。 如果我填充一个集合并将其绑定到 TwoWay 模式下的所有组合框,我会得到:
我想我需要包含一些类似集合的辅助类。该怎么做?
【问题讨论】:
标签: wpf binding observablecollection two-way-binding