StackPanel
is not a control that has a list of values, but it is a container for other controls. Just like I used TableLayout
in the example I give above, you could also use StackPanel.
As for converters, maybe the example from my code below can give you some insight in how to use/bind them.
PropertyViewModel pvm; // defined elsewhere
// text area control
TextArea ta = new TextArea
{
Height = 450,
Width = 250,
DataContext = vm,
AcceptsReturn = true,
AcceptsTab = false,
};
// bind the text to the view-model property StringRepresentation
ta.TextBinding.BindDataContext((PropertyViewModel pvm) => pvm.StringRepresentation);
// create a binding to the boolean property IsStringRepresentationValid
var validBinding = Binding.Property((PropertyViewModel pvm) => pvm.IsStringRepresentationValid);
// convert it to a color binding
var colorBinding = validBinding.Convert(tf => tf ? Colors.White : Colors.PaleVioletRed);
// use the color binding for setting the background.
// end result: the text area shows a white background if the entered string is valid
// and a red background if the entered string is not valid.
ta.Bind(area => area.BackgroundColor, vm, colorBinding);