Hi,
if i have several textboxes in a groupbox that are shown depending on some togglebuttons, how can i display the shown textboxes in sequence?
for example if textbox nr 1 is not shown when a togglebutton is pressed the textbox nr 2 should take the place of textbox nr 1 and nr 3 the place of nr 2 and so on. So it won't be empty space between the boxes.
Loading

Sam HobbsRank #107 · 20.5K reputationPosted Jan 18, 2010, 8:47 AM EST
cleo3 reputationPosted Jan 18, 2010, 10:11 AM EST
and code behind
private void button1_Checked(object sender, RoutedEventArgs e)
{
textbox1.Visibility = Visibility.Hidden;
textbox2.Visibility = Visibility.Visible;
textbox3.Visibility = Visibility.Hidden;
label1.Visibility = Visibility.Hidden;
label2.Visibility = Visibility.Visible;
label3.Visibility = Visibility.Hidden;
}
private void button2_Checked(object sender, RoutedEventArgs e)
{
textbox1.Visibility = Visibility.Visible;
textbox2.Visibility = Visibility.Hidden;
textbox3.Visibility = Visibility.visible;
label1.Visibility = Visibility.Visible;
label2.Visibility = Visibility.Hidden;
label3.Visibility = Visibility.Visible;
}
private void button3_Checked(object sender, RoutedEventArgs e)
{
textbox1.Visibility = Visibility.Visible;
textbox2.Visibility = Visibility.Visible;
textbox3.Visibility = Visibility.Visible;
label1.Visibility = Visibility.Visible;
label2.Visibility = Visibility.Visible;
label3.Visibility = Visibility.Visible;
}
When one of the previous textbox or label is hidden the next visible one should replace it.
I hope this code will help to understand what I mean
Sam HobbsRank #107 · 20.5K reputationPosted Jan 18, 2010, 1:24 PM EST
The buttons are checkboxes, correct? Is it possible for only button 3 to be checked? If so, then your code won't work; you need something more generalized. If however the only way for button 3 to be checked is if the other two buttons are also checked, then I think there are more requirements that are not specified here. In other words, perhaps you did not explain some stuff that is important.
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Jan 19, 2010, 2:32 AM EST
Use 'Visibility.Collapsed' instead of 'Visibility.Hidden'.
That property does not display the element, and does not reserve space for it in layout.
If my answer helps, please do not forget to tick 'Do you like this answer' checkbox.
Martin Cook46 reputationPosted Feb 10, 2010, 2:12 AM EST
You might also benefit from looking up Element Binding and Value Converters.
All the best,
Martin