PropertySetViewModel is in my way

5 posts, 2 answers
  1. Martin
    Martin avatar
    39 posts
    Member since:
    Sep 2008

    Posted 11 Mar 2013 Link to this post

    I am using the PG in this mode: PropertySetMode="Intersection" ,  AutoGeneratePropertyDefinitions="True" 

    I have a property on my object named RequiredCondition, I can se the property in the grid and also the list to choose from but the binding can not find my object because the DataItem is an PropertySetViewModel and not my object.

    What do I do? 

    BindingExpression path error: 'RequiredCondition' property not found on 'object' ''PropertySetViewModel' (HashCode=42488127)'. BindingExpression:Path=RequiredCondition; DataItem='PropertySetViewModel' (HashCode=42488127); target element is 'RadComboBox' (Name=''); target property is 'SelectedItem' (type 'Object')

      <DataTemplate x:Key="RequiredCondition">
            <StackPanel Orientation="Horizontal">
                <telerik:RadComboBox ItemsSource="{Binding Path=DataContext.Conditions, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type views:PropertyEditorView}}, Mode=OneWay}"
                                     DisplayMemberPath="Name"
                                     SelectedItem="{Binding RequiredCondition}" 
                                     EmptyText="Select an Expression" />
            </StackPanel>
        </DataTemplate>
  2. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 14 Mar 2013 Link to this post

    Hi,

    RadPropertyGrid's item is set as DataContext to all of its editors.. When property sets are used, RadPropertyGrid's item is of type PropertySetsViewModel. Apparently, if the property you want to add is not a product of a valid intersection between items' properties, it won't be added in the PropertySetViewModel item, so you cannot bind to it like this. You should explicitly change the Binding's source, since such property does not exist in the DataContext instance.

    All the best,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 14 Mar 2013 Link to this post

    Hi,

    RadPropertyGrid's item is set as DataContext to all of its editors.. When property sets are used, RadPropertyGrid's item is of type PropertySetsViewModel. Apparently, if the property you want to add is not a product of a valid intersection between items' properties, it won't be added in the PropertySetViewModel item, so you cannot bind to it like this. You should explicitly change the Binding's source, since such property does not exist in the DataContext instance.

    All the best,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Martin
    Martin avatar
    39 posts
    Member since:
    Sep 2008

    Posted 14 Mar 2013 Link to this post

    Is it possible for you to see my support ticket where I am asking the same question? I have provided some code that can set the context for my problem
    http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=670183 

    I know that intersection mode is creating a dynamic object. but I do have that property because I can see it without the template, I just want to bind a combobox to it. 
  6. Answer
    Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1127 posts

    Posted 19 Mar 2013 Link to this post

    Hello Martin,

     I have posted a reply to the support ticket yesterday. Will it be possible for you to send us a repro project that we would be able to debug on our side?

    All the best,
    Ivan Ivanov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready