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
Martin CookPosted Feb 10, 2010, 7:12 AM
You might also benefit from looking up Element Binding and Value Converters.
All the best,
Martin
Nilanka DharmadasaPosted Jan 19, 2010, 7:32 AM
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.
Sam HobbsPosted Jan 18, 2010, 6:24 PM
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.
cleoPosted Jan 18, 2010, 3:11 PM
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 HobbsPosted Jan 18, 2010, 1:47 PM