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

Can't create a dependency property of type GridView

0 Answers 86 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alex
Top achievements
Rank 1
Alex asked on 19 Jul 2012, 04:54 AM
In UserControl A I have a dependency property of type GridView:

        public object GridViewObject
        {
            get { return (RadGridView)GetValue(GridViewObjectProperty); }
            set
            {
                SetValue(GridViewObjectProperty, value);
            }
        }
        public static readonly DependencyProperty GridViewObjectProperty =
            DependencyProperty.Register("GridViewObject", typeof(RadGridView), typeof(ColumnSelectorUserControl), null);

In UserControl B I have a control of UserControl A with a GridView object binded to the dependency object of type GridView:
<my:ColumnSelectorUserControl x:Name="ColumnListBox" GridViewControl="{Binding ElementName=GridSearch}" />

I am getting an error:

{System.ArgumentException: Object of type 'System.Windows.Data.Binding' cannot be converted to type 'Telerik.Windows.Controls.RadGridView'.

   at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)

   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)

   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)

   at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)

   at MS.Internal.XamlMemberInfo.SetValue(Object target, Object value)

   at MS.Internal.XamlManagedRuntimeRPInvokes.SetValue(XamlTypeToken inType, XamlQualifiedObject& inObj, XamlPropertyToken inProperty, XamlQualifiedObject& inValue)}

Tags
GridView
Asked by
Alex
Top achievements
Rank 1
Share this question
or