TargetType GridCell does not match Element of Type GridCell

Hi all,

i am just running in an strange Error and need help finding a solution.

We just updated from VS 2019 to 2022. Same Project no changes.

Debugging on "old PC" without any error. Running on Machine with VS 2022 i get the above error.

I found that this is generating the error:

<syncfusion:GridTextColumn.CellStyle>

                        <Style TargetType="syncfusion:GridCell">

                            <Style.Triggers>

                                <DataTrigger Binding="{Binding Path=Dringlichkeit}" Value="Fertig ausgewertet">

                                    <Setter Property="Background" Value="Green" />

                                    <Setter Property="Foreground" Value="White" />

                                </DataTrigger>

                                <DataTrigger Binding="{Binding Path=Dringlichkeit}" Value="Sofort">

                                    <Setter Property="Background" Value="Red" />

                                </DataTrigger>

                                <DataTrigger Binding="{Binding Path=Dringlichkeit}" Value="Eilig">

                                    <Setter Property="Background" Value="Yellow" />

                                </DataTrigger>

                                <DataTrigger Binding="{Binding Path=Dringlichkeit}" Value="PL Fehler">

                                    <Setter Property="Background" Value="HotPink" />

                                </DataTrigger>

                            </Style.Triggers>

                        </Style>

                    </syncfusion:GridTextColumn.CellStyle>


Many thanks in advanced



7 Replies 1 reply marked as answer

SS Sampathnarayanan Sankaralingam Syncfusion Team February 8, 2022 01:46 PM UTC

Hi Tom, 
 
Based on the provided details we have created the sample and checked the reported issue “TargetType GridCell does not match Element of Type GridCell”.  . It is working fine as expected. Please find the tested sample from attachment. However we are in need of some more details. Please provide the following details. 
 
  1. Syncfusion version you are using in your end.
  2. List of all the Syncfusion assemblies referred in your application
  3. Entire Xaml file include namespace section.
 
 
Please have a look at this sample and let us know if we have missed any customization done in your application. Otherwise try to reproduce the reported issue in this sample and revert to us with the modified sample and steps to replicate the issue. It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution. 
 
Regards, 
Sampath Naraynan.S 



TO Tom Oeben February 8, 2022 03:51 PM UTC

Hi,

first of all many thanks for the reply.

I still didn`t find the Error on my side.

Here is a list of all assemblies with the Version and my xml File.

XML-File

Hope to hear from you soon :)


assembly.png



SS Sampathnarayanan Sankaralingam Syncfusion Team February 9, 2022 02:44 PM UTC

Hi Tom,  

We have suspect that you are getting this issue due to the ambiguity in the GridCell and it can be resolved by adding the separate namespace for the DataGrid as shown in below code snippet. 

<Window 
    x:Class="SfDataGridDemo.Chromeless" 
    xmlns:local="clr-namespace:SfDataGridDemo" 
    xmlns:syncfusion=http://schemas.syncfusion.com/wpf 
    xmlns:grid="clr-namespace:Syncfusion.UI.Xaml.Grid;assembly=Syncfusion.SfGrid.WPF"> 
 
<grid:SfDataGrid x:Name="datagrid" 
                                   Margin="10,0,30,30" 
                                   AutoGenerateColumns="False" 
                                   LiveDataUpdateMode="AllowDataShaping" 
                                   ColumnSizer="Auto" AllowEditing="True"  
                                   ItemsSource="{Binding Stocks}" > 
    <grid:SfDataGrid.Columns> 
        <grid:GridTextColumn MappingName="Account"> 
            <grid:GridTextColumn.CellStyle> 
                <Style TargetType="syncfusion:GridCell"> 
                    <Style.Triggers> 
                        <DataTrigger Binding="{Binding Path=Account}" Value="AmericanFunds"> 
                           <Setter Property="Background" Value="Green" /> 
                            <Setter Property="Foreground" Value="White" /> 
                        </DataTrigger> 
                        <DataTrigger Binding="{Binding Path=Account}" Value="RetirementSavings"> 
                            <Setter Property="Background" Value="Red" /> 
                        </DataTrigger> 
                        <DataTrigger Binding="{Binding Path=Account}" Value="Mortages"> 
                            <Setter Property="Background" Value="Yellow" /> 
                        </DataTrigger> 
                        <DataTrigger Binding="{Binding Path=Account}" Value="ChildrenCollegeSavi 
                            <Setter Property="Background" Value="HotPink" /> 
                        </DataTrigger> 
                    </Style.Triggers> 
                </Style> 
            </grid:GridTextColumn.CellStyle> 
        </grid:GridTextColumn> 
       <grid:GridTextColumn MappingName="LastTrade" TextAlignment="Right" /> 
        <grid:GridTextColumn MappingName="PreviousClose" TextAlignment="Right" /> 
        <grid:GridTextColumn MappingName="Open" TextAlignment="Right" /> 
    </grid:SfDataGrid.Columns> 
</grid:SfDataGrid> 
 
 
 


Please revert to us with details if you are still facing the issue. 

Regards, 
Sampath Narayanan.S 


Marked as answer

TO Tom Oeben February 9, 2022 03:45 PM UTC

Many thanks !!

Changing this: 

<Style TargetType="syncfusion:GridCell"> 

also to:

<Style TargetType="grid:GridCell"> 


does the trick.


All running fine now.




SS Sampathnarayanan Sankaralingam Syncfusion Team February 10, 2022 02:09 PM UTC

Hi Tom,


We are glad that the reported issue has been resolved. Please let us know if you require any other assistance from us.


Regards,

Sampath Narayanan.S



PL Paul Lundberg September 16, 2022 02:49 PM UTC

I have exactly the same problem! The suggested solution did not work for me. Some SyncFusion grids work and others give this error,  Ihave so far not been able to figure out why!



DM Dhanasekar Mohanraj Syncfusion Team September 19, 2022 02:06 PM UTC

Hi Paul Lundberg,

We have checked the reported issue on our end. As we mentioned earlier, this issue occurs because of ambiguity in the GridCell and it can be resolved by adding a separate namespace for the DataGrid. Here we have attached the tested sample and the video illustration for resolving the reported issue. Please have a look at this. If you still facing the reported issue, modify the attached sample based on your scenario along with the video illustration of the reported issue. It will be helpful for us to check the cause of the issue and to provide a solution at the earliest. 

Regards,
Dhanasekar M.


If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.


Attachment: SfDataGrid_Demo__91267e5f.zip

Loader.
Up arrow icon