WPF:WindowsServer2003/2008上的DataGridTemplateColumn

WPF:WindowsServer2003/2008上的DataGridTemplateColumn,wpf,wpf-controls,wpfdatagrid,Wpf,Wpf Controls,Wpfdatagrid,我有一个DataGridTemplateColumn: <DataGridTemplateColumn CellStyle="{x:Null}" Width="85" Header="{Extentions:DisplayName Type=Type:StandardClass, PropertyName=ProductKind}"> <DataGridTemplateColumn.CellEditingTemplate>

我有一个
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上进行了测试,结果如下:

我删除了单元格和DataGrid的样式,但仍然
(如您所见)
组合框
项不会出现

最终测试的
相对资源
而不是
元素名称

在浪费了一天的时间后,Win服务器工作正常

解决方案!!:

<DataGridTemplateColumn CellStyle="{x:Null}" Width="85" Header="{Extentions:DisplayName Type=Type:StandardClass, PropertyName=ProductKind}">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox 
                                ItemsSource="{Binding Path=DataContext.ProductKindCollection,RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                      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>

最终测试了
相对资源
,而不是
元素名称

在浪费了一天的时间后,Win服务器工作正常

解决方案!!:

<DataGridTemplateColumn CellStyle="{x:Null}" Width="85" Header="{Extentions:DisplayName Type=Type:StandardClass, PropertyName=ProductKind}">
                    <DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox 
                                ItemsSource="{Binding Path=DataContext.ProductKindCollection,RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                      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>


问题是什么?@Anatoliy Nikolaev:刚才补充道,您是否在其他操作系统下测试了该程序?(Windows XP,Windows 8)。@Anatoliy Nikolaev:不,我没有,但测试了2次胜利7s@Anatoliy尼古拉耶夫:解决了,但我不知道原因!问题是什么?@Anatoliy Nikolaev:刚才补充道,你在其他操作系统下测试过这个程序吗?(Windows XP,Windows 8)。@Anatoliy Nikolaev:不,我没有,但测试了2次胜利7s@Anatoliy尼古拉耶夫:解决了,但我不知道原因!