I am using RADGRIDVIEW to display a data. i havent register any event handler for gridview but still on double click of any row( or GridViewDataColumn) it throws an silverlight error
"Unhandled error in silverlight application code:4004
Category: ManagedRunTimeError
message: invalidecast exception: unable to cast object of type telerik.windows.controls.gridviewdatacolumn"
I also tried to set the IsReadOnly propety to true but stil it is not working.
Colud you please help me
Thanks,
Nikhil Kolte
5 Answers, 1 is accepted
May you please share with us the source code you are currently using?
Vanya Pavlova
the Telerik team
Hi,
Following is the xaml code
<telerik:RadGridView IsReadOnly="True" VerticalAlignment="Top" Height="262" x:Name="GenericGridView" ItemsSource="{Binding PagedSource, ElementName=ItemsPager, Mode=TwoWay}" Margin="6,0,0,10" AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn IsReadOnly="True" Width="239" Header="Title" DataMemberBinding="{Binding Name}" ToolTipService.ToolTip="{Binding Name}">
<telerik:GridViewDataColumn.ToolTipTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</telerik:GridViewDataColumn.ToolTipTemplate>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="dd-MM-yyyy" Width="70" Header="Joining Date" DataMemberBinding="{Binding JoinDate}" >
</telerik:GridViewDataColumn>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<telerik:RadDataPager x:Name="ItemsPager" PageSize="8" DisplayMode="FirstLastPreviousNextNumeric" IsTotalItemCountFixed="False" VerticalAlignment="Top" Margin="2,268,-6,0" Background="Transparent" BorderThickness="0" Canvas.ZIndex="100" Source="{Binding EmployeeDetails,Mode=TwoWay}" />
Thank you for sharing this snippet with us! I tried to replicate such a behavior, but I was not able to get such an exception using this snippet. May you please check the attached project and let me know how it differs from yours? Any additional information about the grid version you used would be highly appreciated as well.
Also you may send to us a runnable project in a new support ticket where we can see what is going on.
Vanya Pavlova
the Telerik team
The issue was,In GridViewDataColumn i am setting tool tip for that grid column as shown below
<telerik:GridViewDataColumn IsReadOnly="True" Width="239" Header="Title" DataMemberBinding="{Binding Name}" ToolTipService.ToolTip="{Binding Name}">
but when i removed this is started working. dont know how it works at your code snipet.
i am pasting exact exception thrown by it just for your reference :)
Microsoft JScript runtime error: Unhandled Error in Silverlight Application Unable to cast object of type 'Telerik.Windows.Controls.GridViewDataColumn' to type 'System.Windows.UIElement'. at System.Windows.Controls.ToolTipService.OnToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
at System.Windows.Data.BindingExpression.SendDataToTarget()
at System.Windows.Data.BindingExpression.SourceAcquired()
at System.Windows.Data.BindingExpression.InheritanceContextChanged(Object sender, EventArgs e)
at System.Windows.DependencyObject.OnInheritanceContextChanged(Object sender, EventArgs e)
at System.Windows.DependencyObject.SetEffectiveValue(DependencyProperty property, EffectiveValueEntry& newEntry, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCurrentCellInfoChanged(GridViewCellInfo currentCell)
at Telerik.Windows.Controls.GridView.GridViewDataControl.set_CurrentCellInfo(GridViewCellInfo value)
at Telerik.Windows.Controls.GridView.GridViewCell.UpdateOnIsCurrentChanged(Boolean newValue)
at Telerik.Windows.Controls.GridView.GridViewCell.IsCurrentChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e)
at Telerik.Windows.PropertyMetadata.<>c__DisplayClass1.<Create>b__0(DependencyObject d, DependencyPropertyChangedEventArgs e)
at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object oldValue, Object newValue)
at System.Windows.DependencyObject.UpdateEffectiveValue(DependencyProperty property, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, ValueOperation operation)
at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet)
at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCellMouseDown(GridViewCell cell, MouseButtonEventArgs args)
at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
at System.Windows.Controls.Control.OnMouseLeftButtonDown(Control ctrl, EventArgs e)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)
and the GridView version is : 2010.3.1314.1040
Thank you for your quick response. i really appreciate your customer orientation
Thanks
This could be an issue related to the grid version you used. May you please try our latest official binaries and let me know whether the issue still persists? If so, I believe that the best option would be to open a separate support ticket where you can attach sample application. This would help us better understand what the problem is and help us better assist to you in fixing it.
Vanya Pavlova
the Telerik team