This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi. I'm using custom control for custom class that I add to PropertyGrid.ItemsSource. This control is based on wpfs TreeView. But I have faced with problem: there no expanding tree when I try to do this. In output appears next message: System.Windows.Data Error: 8 : Cannot save value from target back to source. BindingExpression:Path=IsExpanded; DataItem='TreeViewItem' (Name=''); target element is 'ToggleButton' (Name='Expander'); target property is 'IsChecked' (type 'Nullable`1') InvalidCastException:'System.InvalidCastException: Не удалось привести тип объекта "System.String" к типу "Mindscape.WpfElements.WpfPropertyGrid.PropertyGridRow". I've developed some sample that demonstrate this problem: http://www.2shared.com/file/h-jzlMGI/ProrertyGrid__TreeViewProblemS.html Just to run this solution and try to expand the tree. Can I get the ordinary behavior in this context. P.S. Sorry about my English |
|
|
This occurs because the property grid listens for bubbling Expanded and Collapsed events from its internal tree view items. Your tree view items are also raising Expanded and Collapsed events, and these are bubbling up to the property grid which thinks they are its own and tries to act on them. To work around this, just add event handlers in your user control to stop the Expanded and Collapsed events bubbling outside the user control. In the LinkEditor constructor, add the following lines: xmlTreeView.AddHandler(TreeViewItem.ExpandedEvent, new RoutedEventHandler(StopBubbling)); And implement the StopBubbling method to basically do nothing: private void StopBubbling(object sender, RoutedEventArgs e) |
|
|
Thank you for reply and help, Ivan. |
|