WPF DataGrid中ComboBox绑定后数据不更新问题求助
WPF DataGrid中ComboBox绑定后数据不更新问题求助
嘿各位大佬,我碰到一个棘手的问题:我写的WPF代码里,在DataGrid的单元格编辑模板里用了RadComboBox,但是选择完选项后DataGrid就是不更新显示,也没有任何报错信息。
奇怪的是,用List<string>作为数据源的时候这个逻辑是正常的,但换成List<Model>就不行了。我感觉应该是要把DataGrid的数据和ComboBox的数据做某种关联来触发更新,但具体怎么操作我摸不着头绪,有没有人能给点建议呀?
UPDATE:补充下背景信息,方便大家排查:
CodeCategories是一个独立的集合,里面只有Code_Category和Code_Category_Id两个字段;- 我用了单独的ViewModel来填充DataGrid,ViewModel里的实体包含
Code_Category_Id字段,就是用来和CodeCategories做关联的。
以下是相关的XAML代码:
<telerik:GridViewDataColumn Width="350" Header="CODE CATEGORY" HeaderTextWrapping="Wrap" HeaderCellStyle="{StaticResource mainHeader}"> <telerik:GridViewDataColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding CODE_CATEGORY, Mode=TwoWay}"></TextBlock> </DataTemplate> </telerik:GridViewDataColumn.CellTemplate> <telerik:GridViewDataColumn.CellEditTemplate> <DataTemplate> <telerik:RadComboBox ItemsSource="{Binding DataContext.CodeCategories, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" SelectedValue="{Binding CODE_CATEGORY_ID, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="CODE_CATEGORY" SelectedValuePath="CODE_CATEGORY_ID"> </telerik:RadComboBox> </DataTemplate> </telerik:GridViewDataColumn.CellEditTemplate> </telerik:GridViewDataColumn>
备注:内容来源于stack exchange,提问作者chrisg229
相关产品推荐
相关产品推荐

