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

PropertySetViewModel is in my way

4 Answers 70 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 2
Martin asked on 11 Mar 2013, 02:42 PM
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>

4 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Ivanov
Telerik team
answered on 14 Mar 2013, 11:51 PM
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.

0
Ivan Ivanov
Telerik team
answered on 14 Mar 2013, 11:51 PM
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.

0
Martin
Top achievements
Rank 2
answered on 15 Mar 2013, 12:10 AM
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. 
0
Accepted
Ivan Ivanov
Telerik team
answered on 19 Mar 2013, 03:57 PM
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.

Tags
PropertyGrid
Asked by
Martin
Top achievements
Rank 2
Answers by
Ivan Ivanov
Telerik team
Martin
Top achievements
Rank 2
Share this question
or