【发布时间】:2015-09-29 12:50:12
【问题描述】:
在我的项目中,我有一个包含三个组合框模板列的数据网格。组合框是使用 xaml 进行数据绑定的。但是当我运行项目组合框时显示 system.data.dataRowView 。这是我的数据网格单元代码
<DataGridTemplateColumn Header="Category" Width="*" x:Name="categoryColumn">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox x:Name="categoryBox"
IsEditable="True"
fa:FocusAttacher.Focus="True"
controls:TextBoxHelper.ClearTextButton="True"
controls:TextBoxHelper.SelectAllOnFocus="True"
controls:TextBoxHelper.Watermark="Category"
MaxDropDownHeight="125"
SelectionChanged="CategoryBox_OnSelectionChanged"
IsSynchronizedWithCurrentItem="True"
DisplayMemberPath="{Binding CategoriesCollection.Columns[1]}"
SelectedValuePath="{Binding CategoriesCollection.Columns[0]}"
ItemsSource="{Binding Path=DataContext.CategoriesCollection.DefaultView,
RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
为什么它没有显示正确的数据。任何人都可以建议我解决这个问题的方法
【问题讨论】:
-
去掉
DisplayMemberPath和SelectedValuePath绑定路径中的CategoriesCollection.应该是{Binding Path=Columns[1]} -
你还在收到
system.data.dataRowView -
是的,没有任何改变
标签: c# wpf combobox wpfdatagrid datagridtemplatecolumn