This is a migrated thread and some comments may be shown as answers.

Error: A value of type 'GridViewDataColumn' cannot be added to a collection or dictionary of type 'GridViewColumnCollection'.

7 Answers 1059 Views
GridView
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 03 Nov 2014, 03:14 PM
Hi,

Can someone tell me why I keep getting the following error when I try to set a CellStyle on a GridViewDataColumn in a RadGridView control?

Error: A value of type 'GridViewDataColumn' cannot be added to a collection or dictionary of type 'GridViewColumnCollection'.

Here is the xaml:

    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name">
     <telerik:GridViewDataColumn.CellStyle>
           <Style BasedOn="{StaticResource ReadOnlyStyle}" TargetType="{x:Type telerik:GridViewCell}" />
     </telerik:GridViewDataColumn.CellStyle>
    </telerik:GridViewDataColumn>

All I am trying to do is create a style - ReadOnlyStyle - that would set the foreground color of a grid column to a gray color when the style is set. Here is the style:

    <!--  GridView: Read Only Style  -->
    <Style x:Key="ReadOnlyStyle" TargetType="telerik:GridViewCell">
        <Setter Property="Foreground" Value="{DynamicResource ForegroundReadOnlyColor}" />
        <Setter Property="IsHitTestVisible" Value="False" />
    </Style>

Thanks!

7 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 06 Nov 2014, 09:07 AM
Hi George,

I tried to reproduce the mentioned error, however I was unsuccessful. Could you please edit the attached sample project in a way that it reproduces the issue? In addition from your picture I noticed that the style is applied.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Michael
Top achievements
Rank 1
answered on 20 Apr 2015, 02:28 PM
Did you ever figure this out? I found that this happens a lot to me but if I restart Visual Studio the errors go away... until after X number of builds they show up again. Frustrating.
0
Vanya Pavlova
Telerik team
answered on 20 Apr 2015, 03:57 PM
Hi Michael,


Generally errors of this type are raised when you have some type mismatch in a well-formed document. 
Everything with the provided mark-up is right, you could find more info for these exceptions, here. 
For the time being I may suggest you to check the type required by the collection once this error occured.
In addition to this checking the version of all required assemblies for the grid might be of help. 



Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Michael
Top achievements
Rank 1
answered on 21 Apr 2015, 03:20 PM
I'm only adding telerik:gridViewDataColumn to <telerik:RadGridView.Columns>
The project will build and run despite the errors (which is evidence that they are not really errors). If I close visual studio and reopen it they go away.
0
Vanya Pavlova
Telerik team
answered on 21 Apr 2015, 03:44 PM
Hi Michael,


You may try to update the ToolBox configurator via the following VS menu option:  Telerik - UI for WPF - "Launch Toolbox configurator".

Please give it a try and let me know how I could assist you further. 


Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Michael
Top achievements
Rank 1
answered on 21 Apr 2015, 04:38 PM

I'm not sure what you're saying. The tools in the toolbox affect how the xaml code is parsed in the designer?

I updated it to UI for v.2015.1.401.45 (Dev) [Download] but I'm not sure that wasn't what was already configured. Please see the screenshot I attached to my last post.

0
Vanya Pavlova
Telerik team
answered on 24 Apr 2015, 10:10 AM
Hi Michael,


I've checked the image attached to the previous post once again. Looking at the errors you are getting I suppose that something went wrong with the assemblies. The mark-up looks correctly defined.    
Some customers experience problems similar to the yours and this option helped to resolve this problem.

You could check the following forum thread for further reference. The same is applicable to WPF, as well. 
  
In order to avoid additional round trips, I believe that the best option would be to try to isolate the problem in a runnable project. It could be attached in a separate support thread and would help us a lot. 



Regards,
Vanya Pavlova
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
GridView
Asked by
George
Top achievements
Rank 1
Answers by
Boris
Telerik team
Michael
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or