Selection in ListBox
-
2012년 3월 5일 월요일 오전 3:06
Hi
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.
.NET guy
- 편집됨 tsadigov 2012년 3월 5일 월요일 오전 3:08
모든 응답
-
2012년 3월 6일 화요일 오전 9:03anyone?
.NET guy
-
2012년 3월 8일 목요일 오전 3:15중재자
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
- 답변으로 표시됨 Kee PoppyModerator 2012년 3월 13일 화요일 오전 5:48

