tags:

views:

30

answers:

2

This is a bit of a difficult problem to explain, but I'm hoping it has a reasonably simple resolution.

I am writing a Listbox control in XAML and most of the layout for the ListBox.ItemTemplate laid out in a grid is the same throughout the list. However the listbox is a "Problem Resolver" that picks out anomalies in a list of customer orders and asks the user to make some decision, or change to the data, before allowing it into the postage system which will bill us for despatching a customer's order.

The problem types are described in an enum with three settings, for two out of the three problem statuses I need a text description of the problem (different description for each type of problem and with dynamic data included in the text) and a button, for the last problem type I need a text description and a radiobutton list.

Is there any way to include a sort of switch statement in the XAML which will decide which content to put in the grid cell where the content needs to vary by just telling it what the Enum value is for the problem order?

+1  A: 

That could be achieved by DataTemplateSelector

Veer
This appears to work. Unfortunately without building an entire demo app just to test it all I know is my solution compiles. Still, it's definitely a step in the right direction. Thanks!
bert
+1  A: 

Try to use the Switch Converter written by Josh, should work for you:

SwitchConverter – A "switch statement" for XAML - http://josheinstein.com/blog/index.php/2010/06/switchconverter-a-switch-statement-for-xaml/

akjoshi