Can't create a dependency property of type GridView

1 posts, 0 answers
  1. Alex
    Alex avatar
    2 posts
    Member since:
    Jun 2012

    Posted 18 Jul 2012 Link to this post

    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)}

Back to Top