【发布时间】:2015-05-24 11:25:10
【问题描述】:
我遇到了数据绑定问题。我有一个 WPF (MVVM) 用户控制项目。有Comboboxes 和Labels。每个ComboBox 绑定到一个ObservableDictionary<int,string>。所以我的问题是我只需要在我的ComboBox 上显示字典的字符串部分。
此外,Combobox ItemSource 的更改取决于在之前的 ComboBox 中选择的内容。这也是 MVVM 模式。有模型和视图模型。
我尝试设置DisplayPathetc。但我不能只显示连击的字符串。总是看到[0, sample]、[1,yes]。
<ComboBox HorizontalAlignment="Left" Margin="250,15,0,0" VerticalAlignment="Top" Width="120" Name="CBxerisim" SelectionChanged="CBxerisim_SelectionChanged" ItemsSource="{Binding Derisimkodu}" />
<ComboBox HorizontalAlignment="Left" Margin="250,45,0,0" VerticalAlignment="Top" Width="120" Name="CBxteklifDurum" SelectionChanged="CBxteklifDurum_SelectionChanged" ItemsSource="{Binding Dteklifdurumu}"/>
<ComboBox HorizontalAlignment="Left" Margin="250,75,0,0" VerticalAlignment="Top" Width="120" Name="CBxteklifSonuc" SelectionChanged="CBxteklifSonuc_SelectionChanged" ItemsSource="{Binding Dteklifsonuc}"/>
【问题讨论】: