Quantcast
Viewing all articles
Browse latest Browse all 7205

How to: Use the PropertyGrid to Manage Collection Properties

This example shows how to manage collection properties and implement item initializers in the Property Grid.

Question Comments

Added By: Andrew Roberts 5 at: 11/5/2014 3:02:37 PM    

I am trying to use this example but the ItemInitializer class needs to be in a ViewModel and the dxprg:CollectionDefinition is part of a DataTemplate in a separate file. I can't use NewItemInitializer as suggested in this sample.

Tried:
NewItemInitializer="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=DataContext.ItemInitializer}"

Received error:
System.Windows.Data Error: 40 : BindingExpression path error: 'ItemInitializer' property not found on 'object' ''WorkstationsEditorViewModel' (HashCode=43595579)'. BindingExpression:Path=DataContext.ItemInitializer; DataItem='WorkstationsEditorView' (Name='workstationsEditorView'); target element is 'CollectionDefinition' (Name=''); target property is 'NewItemInitializer' (type 'IInstanceInitializer')

So it’s looking for a property on WorkstationsEditorViewModel

So I did this on the ViewModel:

public ItemInitializer ItemInitializer {
           get { return new ItemInitializer();}

Now not throwing errors, but I'm not getting the Collection property showing in the Property Grid

Added By: Andrey Kunitsyn (DevExpress Support) at: 11/5/2014 11:41:05 PM    


Hello,

To process your recent post more efficiently, I created a separate ticket on your behalf: T169706: Example E4855 - Moving ItemInitialized to the View Model raises a binding exception. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Thanks,
Andrey


Viewing all articles
Browse latest Browse all 7205

Trending Articles