I\'m relatively new to DataBinding and just reading into it. What I want to do is the following:
I have a StackPanel with a number of child controls:
Have you considered setting the visibility of the TextBoxes to Hidden
? This will "hide" the space that is assigned for the TextBoxes. Assuming their are no other controls in the StackPanel, then it will not be visible.
Of course, this solution may make some naive assumptions about your implementation.
If you need the more complex scenario, I would attempt the following: Note: This is psuedocode - may not compile..
1) Use a MultiBinding
2) Declare the Converter
3) Define the Converter
public class VisibilityConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
Visibility text1Vis = (Visibility)values[0];
Visibility text2Vis = (Visibility)values[1];
Visibility text3Vis = (Visibility)values[2];
if (text1Vis == text2Vis == text3Vis == Visibility.Collapsed)
return Visibility.Collapsed;
return Visibility.Visible;
}
}