I have a UI issue with layered editing where a different set of tools needs to be visible depending on the ComboBox selecting the layer and am stewing over the idiom to use. The tools should not be in a visible container.
The ComboBox selection is bound to a simple integer property in the ViewModel.
The alternatives I've been considering are mostly based around a series of StackPanel containers at the same location:
- Bind the
StackPanels' visibility properties to a different ViewModel property for each, then have those visibility properties calculate based on the Combo's backing value. I will have to add some further notification to ensure they refresh when the Combo changes. - Use a
ValueConverterto bindStackPanels' visibility properties directly to the Combo selection - Put the
StackPanels in each of theTabItems in aTabControland suppress any drawing of header, so theTabControlselection can be mapped directly to the Combo selection. - Use a
Selectorsubclass or just templating a Selector to开发者_StackOverflow中文版 get the behaviour of 3 without any baggage fromTabControl. - The approach I'm using for now - added a
Clickhandler to the popup on which their visibility is supposed to depend and simply set the visibility of the different panels according to that popup'sSelectedIndex. Very old-school but simple and easy to follow code.
I vote for #1. I know the WPF purists will say that this is a bit "old school" and there are better ways of handling it. But sometimes you just need some basic examples of old functionality and KISS is the best way to go about it.
加载中,请稍侯......
精彩评论