Hi, I have the following case:
1. Item type is ICustomTypeProvider implementation. It has 2 dynamic properties: decimal Value and bool IsReadonly.
2. I'm setting a collection of such items as an ItemsSource for RadGridView.
3. I'm creating 1 GridViewDataColumn for Value property which has DataType set to decimal. IsReadonlyBinding for the column is bound to the IsReadonly property of the object.
4. When trying to edit cell, I'm getting the following exception:
(Further investigation shown that Unbox tries to cast value to the type of column (which is decimal) while value returned by IsReadonly is bool)
Specified cast is not valid.
System.Exception: Specified cast is not valid. ---> System.InvalidCastException: Specified cast is not valid.
at Telerik.Windows.Data.Expressions.UnboxT`1.ValueField(Object value)
at Telerik.Windows.Data.Expressions.CustomTypeProviderExtensions.Property[T](Object component, String propertyName)
at Telerik.Windows.Data.Expressions.CustomTypeProviderExtensions.Property[T](ICustomTypeProvider typeProvider, String propertyName)
at lambda_method(Closure , MetricRow )
at Telerik.Windows.Data.FuncExtensions.<>c__DisplayClass1`2.<ToUntypedFunc>b__0(Object item)
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 editEventArgs)
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)
1. Item type is ICustomTypeProvider implementation. It has 2 dynamic properties: decimal Value and bool IsReadonly.
2. I'm setting a collection of such items as an ItemsSource for RadGridView.
3. I'm creating 1 GridViewDataColumn for Value property which has DataType set to decimal. IsReadonlyBinding for the column is bound to the IsReadonly property of the object.
4. When trying to edit cell, I'm getting the following exception:
(Further investigation shown that Unbox tries to cast value to the type of column (which is decimal) while value returned by IsReadonly is bool)
Specified cast is not valid.
System.Exception: Specified cast is not valid. ---> System.InvalidCastException: Specified cast is not valid.
at Telerik.Windows.Data.Expressions.UnboxT`1.ValueField(Object value)
at Telerik.Windows.Data.Expressions.CustomTypeProviderExtensions.Property[T](Object component, String propertyName)
at Telerik.Windows.Data.Expressions.CustomTypeProviderExtensions.Property[T](ICustomTypeProvider typeProvider, String propertyName)
at lambda_method(Closure , MetricRow )
at Telerik.Windows.Data.FuncExtensions.<>c__DisplayClass1`2.<ToUntypedFunc>b__0(Object item)
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 editEventArgs)
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)