This question is locked. New answers and comments are not allowed.
Getting a NullReferenceException when trying to use IsReadOnlyBinding on a GridViewDataColumn.
LabDetails is a collection of "LabDetail". But I do not have a property on LabDetail that identifies whether it is read only or not. I want to use a property on the ViewModel "SelectedLabDetailEditable" which does identify whether that particular LabDetail should be editable.
So either I have a problem with my binding to that property, or it would seem that this IsReadOnlyBinding doesn't support using properties that are not on the entity that the Grid is bound to.
It seems that my binding statement is correct, I bound that to a simple textblock and the property is updated and correct as my SelectedLabDetail changes:
The stack trace of the exception is:
LabDetails is a collection of "LabDetail". But I do not have a property on LabDetail that identifies whether it is read only or not. I want to use a property on the ViewModel "SelectedLabDetailEditable" which does identify whether that particular LabDetail should be editable.
So either I have a problem with my binding to that property, or it would seem that this IsReadOnlyBinding doesn't support using properties that are not on the entity that the Grid is bound to.
<
telerik:RadGridView
AutoGenerateColumns
=
"False"
ItemsSource
=
"{Binding LabDetails}"
SelectedItem
=
"{Binding SelectedLabDetail}"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"Result"
DataMemberBinding
=
"{Binding TokenValue}"
IsReadOnlyBinding
=
"{Binding DataContext.SelectedLabDetailEditable, ElementName=LayoutRoot}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
It seems that my binding statement is correct, I bound that to a simple textblock and the property is updated and correct as my SelectedLabDetail changes:
<
TextBlock
Text
=
"{Binding DataContext.SelectedLabDetailEditable, ElementName=LayoutRoot}"
/>
The stack trace of the exception is:
at Telerik.Windows.Controls.GridViewBoundColumnBase.EvaluateIsReadOnlyState(Object item)
at Telerik.Windows.Controls.GridViewBoundColumnBase.CanEdit(Object item)
at Telerik.Windows.Controls.GridView.GridViewDataControl.BeginEdit(GridViewCell gridViewCell, RoutedEventArgs editingEventArgs)
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, UInt32 flags)