5

I'm developing a WPF applicaition to try and get a better understanding of what it's about and what it can do. I've got a situation though which I'm not sure how best to implement, where basically my UI needs to change depending on user selection.

Essentially I wish to build up a set of 'ConditionRows', where the user specifies a 'Field' and 'Condition' and a 'Style' to use if that condition matches. I imagine the layout to be similar to that below.

alt text http://img63.imageshack.us/img63/1813/39321945.jpg

What I need to do is change what is displayed in the 'Control 1' (either a textbox, or 2 textboxes and a label, or nothing) and 'Control 2' (either a bound combobox, numeric up/down, colour picker). I'm not quite sure the best way to dynamically change these controls though and keep the code/xaml separation as much as possible.

1 Answer 1

3

If you are doing MVVM, you can make the child ViewModel for each control area a polymorphic property of the main ViewModel (i.e. IControlGroupViewModel, and a concrete ViewModel for each possible control grouping). Then you can then create a data template for each concrete type in a resource dictionary. If you bind the view to the polymorphic property, the correct datatemplate should be chosen at run time.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.