TreeView

Jun 18, 2010 at 2:23 AM

Is there a sample available that binds a TreeView control, and the nested TreeViewItems? I looked at the DataContextAware sample, but I am not sure how to properly apply that to a TreeViewItem.


Thanks
David 

Coordinator
Jun 18, 2010 at 8:50 AM
Binding to a tree view has nothing to do with MEFedMVVM... it is a normal binding... Are you having any issue?



Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App



On Fri, Jun 18, 2010 at 2:23 AM, dbuksbaum <notifications@codeplex.com> wrote:

From: dbuksbaum

Is there a sample available that binds a TreeView control, and the nested TreeViewItems? I looked at the DataContextAware sample, but I am not sure how to properly apply that to a TreeViewItem.


Thanks
David 

Read the full discussion online.

To add a post to this discussion, reply to this email (MEFedMVVM@discussions.codeplex.com)

To start a new discussion for this project, email MEFedMVVM@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com


Jun 18, 2010 at 12:41 PM

Thanks for the quick reply. Ok, my mistake for lack of clarity. While the TreeView can be bound, and HierarchialDataTemplate can be defined with binding, I am having a problem assigning a ViewModel to the specific items. Specifically, I was working from Josh Smith's MVVM/TreeView article (http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx) in which the actual TreeViewItems map to a ViewModel. I was thinking that this could be done using the DataContextAware functionality.

The real problem is being able to track (at a minimum) the SelectedItem in the TreeView. As this is not a settable property, it doesn't work for binding. So it becomes necessary to use the IsSelected property on the individual item, and bind to that.

Thanks

David

 

Coordinator
Jun 21, 2010 at 7:55 AM
here is an example of how you can use 1 ViewModel instead of a viewmodel per TreeviewItem
http://stackoverflow.com/questions/2848987/cannot-seem-to-communicate-between-views/2849526#2849526

You can even go an extra level and create an attached property to do this.


Regards
Marlon
WPF Blog - http://marlongrech.wordpress.com/
Microsoft MVP for Client App



On Fri, Jun 18, 2010 at 12:41 PM, dbuksbaum <notifications@codeplex.com> wrote:

From: dbuksbaum

Thanks for the quick reply. Ok, my mistake for lack of clarity. While the TreeView can be bound, and HierarchialDataTemplate can be defined with binding, I am having a problem assigning a ViewModel to the specific items. Specifically, I was working from Josh Smith's MVVM/TreeView article (http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx) in which the actual TreeViewItems map to a ViewModel. I was thinking that this could be done using the DataContextAware functionality.

The real problem is being able to track (at a minimum) the SelectedItem in the TreeView. As this is not a settable property, it doesn't work for binding. So it becomes necessary to use the IsSelected property on the individual item, and bind to that.

Thanks

David

 

Read the full discussion online.

To add a post to this discussion, reply to this email (MEFedMVVM@discussions.codeplex.com)

To start a new discussion for this project, email MEFedMVVM@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com