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

3 Replies

MS Madhavan Sathapillai Syncfusion Team March 20, 2026 08:36 AM UTC

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



?? ?? ? March 23, 2026 08:21 AM UTC

The problem has been resolved. Thank you very much, it is indeed the problem that caused it.



SR Senthilkumar Ranganathan Syncfusion Team March 24, 2026 06:52 AM UTC

liuhaor,
Glad that your requirement is fulfilled! We are closing this ticket now. Please open a new ticket if you need any assistance, we will be happy to help you.

Loader.
Up arrow icon