lunedì 5 marzo 2012 03:06
I have 2 level hierarchy in my viewModel (Module,Item)
in left pane I want to show this hierarchy. I use ListBox with Expander as ItemTemplate
and in right pane show selected item.
The Problem I have is that I cannot make WPF automatically select Module(level1) when user selects the Item(level2)
It seems like the deeper level control intercepts RoutedEvent so it does not propogate up.
- Modificato tsadigov lunedì 5 marzo 2012 03:08
Tutte le risposte
martedì 6 marzo 2012 09:03anyone?
giovedì 8 marzo 2012 03:15Moderatore
You bound the Model with ListBox and you should design the DataTemplate for the Model type in View. Then you select one item in the ListBox, you could attach one command to the ListBox SelectionChanged event in your ViewModel. And notify the level 1 item to change its IsSelected property. You should bind the IsSelected property of level 1 item Model to the left panel ListBoxItem style.
So AttachedCommand in MVVM can help you to map the routed event from View into ViewModel, such as behaviour: http://www.codeproject.com/Articles/28959/Introduction-to-Attached-Behaviors-in-WPF
and AttachedCommand: http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/
Bob Bao [MSFT]
MSDN Community Support | Feedback to us
- Contrassegnato come risposta Kee PoppyModerator martedì 13 marzo 2012 05:48