【发布时间】:2013-08-31 15:31:12
【问题描述】:
我有一个DataGridTemplateColumn:
<DataGridTemplateColumn CellStyle="{x:Null}" Width="85" Header="{Extentions:DisplayName Type=Type:StandardClass, PropertyName=ProductKind}">
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding ElementName=viewSourceDataGrid, Path=DataContext.ProductKindCollection}"
DisplayMemberPath="Title" Style="{x:Null}"
SelectedValue="{Binding ProductKind, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock
Text="{Binding ProductKind.Title, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
也试过了:
<DataGridComboBoxColumn Header="{Extentions:DisplayName Type=Type:StandardClass, PropertyName=ProductKind}"
DisplayMemberPath="Title"
SelectedItemBinding="{Binding ProductKindID, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True,ValidatesOnDataErrors=True}">
<DataGridComboBoxColumn.ElementStyle>
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource EditBaseStyle}">
<Setter Property="ItemsSource" Value="{Binding ElementName=viewSourceDataGrid, Path=DataContext.ProductKindCollection}" />
</Style>
</DataGridComboBoxColumn.ElementStyle>
<DataGridComboBoxColumn.EditingElementStyle>
<Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource EditBaseStyle}">
<Setter Property="ItemsSource" Value="{Binding ElementName=viewSourceDataGrid, Path=DataContext.ProductKindCollection}" />
</Style>
</DataGridComboBoxColumn.EditingElementStyle>
</DataGridComboBoxColumn>
在 win 7 上一切正常,但在 win server 2008 和 2003 上进行了测试,结果:
我删除了 cell 和 DataGrid 的样式,但仍然
(如您所见)ComboBox 项目没有出现
【问题讨论】:
-
问题是什么?
-
@Anatoliy Nikolaev:刚刚添加
-
你在其他操作系统下测试过程序吗? (Windows XP、Windows 8)。
-
@Anatoliy Nikolaev:不,我没有,但在 2 胜 7 秒上测试过
-
@Anatoliy Nikolaev:已解决,但我不知道原因!
标签: wpf wpf-controls wpfdatagrid