System Invalid OperationException The GridCell targetType does not match the type of the element GridCell
28.1.39 Syncfusion-SfGrid-WPF and Syncfusion-SfSpreadsheet. WPF with the same version number cause a System. Invalid OperationException: "The 'GridCell' targetType does not match the type of the element 'GridCell'
When I tried to introduce Syncfusion. SfSpreadsheet. WPF of the same version 28.1.39. Adding data to the table will trigger this exception. After removing the package of this NuGet, it works normally
<syncfusion:SfDataGrid
Grid.Row="1"
Margin="10,0,10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowSorting="False"
AutoGenerateColumns="False"
Background="Transparent"
BorderBrush="#68d8fe"
ColumnSizer="Star"
FontFamily="{StaticResource PingFang}"
FontSize="12"
FontWeight="Bold"
Foreground="{StaticResource FontColor9}"
HeaderRowHeight="35"
ItemsSource="{Binding SchemeNameList}"
RowHeight="40"
SelectedItem="{Binding SelectedSchemeName, Mode=TwoWay}"
SelectionMode="Single"
SelectionUnit="Row"
Style="{StaticResource SfDataGridStyle1}">
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridTemplateColumn
Width="50"
AllowEditing="True"
AllowFocus="False"
HorizontalHeaderContentAlignment="Center"
MappingName="IsSelected">
<syncfusion:GridTemplateColumn.HeaderTemplate>
<DataTemplate>
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding DataContext.IsSelectedAllName, RelativeSource={RelativeSource AncestorType=Window}, Mode=TwoWay}" />
</DataTemplate>
</syncfusion:GridTemplateColumn.HeaderTemplate>
<syncfusion:GridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsChecked="{Binding IsSelected, Mode=TwoWay}" />
</DataTemplate>
</syncfusion:GridTemplateColumn.CellTemplate>
</syncfusion:GridTemplateColumn>
<syncfusion:GridTextColumn
HeaderText="{loc:Loc 方案名称}"
MappingName="SchemeName"
TextAlignment="Center" />
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
<Style x:Key="SfDataGridStyle1" TargetType="{x:Type syncfusion:SfDataGrid}">
<Setter Property="RowStyle" Value="{StaticResource DarkRowStyle1}" />
<Setter Property="HeaderStyle" Value="{StaticResource DarkHeaderStyle1}" />
<Setter Property="CellStyle" Value="{StaticResource DarkCellStyle1}" />
<Setter Property="RowSelectionBrush" Value="#115167" />
<Setter Property="SelectionForegroundBrush" Value="White" />
</Style>
<Style x:Key="DarkCellStyle1" TargetType="syncfusion:GridCell">
<Setter Property="Padding" Value="5,0" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="1,1,1,0" />
<Setter Property="BorderBrush" Value="#68d8fe" />
</Style>
Attachment: xaml_354b1eab.txt
Hi liuhaor,
We have analyzed your query and were able to replicate the Ambiguous Type
Reference Exception issue at our end when using both Syncfusion.SfSpreadsheet.WPF
and Syncfusion.SfGrid.WPF NuGet packages.
This exception occurs because both packages internally reference assemblies that contain classes with the same type names (for example, GridCell). When WPF encounters these overlapping types, it cannot determine which one to use, resulting in the ambiguity error.
For detailed guidance on resolving this issue, please refer to our Knowledge Base article:
How to resolve ambiguous type reference exception in WPF DataGrid
Kindly review
the article and let us know if you need any further assistance.
Regards,
Madhavan S
The problem has been resolved. Thank you very much, it is indeed the problem that caused it.
- 3 Replies
- 3 Participants
-
?? ?? ?
- Mar 19, 2026 09:58 AM UTC
- Mar 24, 2026 06:52 AM UTC