I would like to hide several textboxes, a label and a button as soon as a button is clicked... however, for some reason, my code doesn't seem to cause this effect. Nothing appears to happen. I'm using WPF.
Here is my code:
private void doSomething_Click(object sender, RoutedEventArgs e)
{
Name.Visibility = Visibility.Hidden;
}
This code doesn't seem to work.. any ideas?
I believe Visibility.Collapsed
is what you need and not Visibility.Hidden
.
EDIT: Did you try follow up this code with UpdateLayout()
method of parent element/component?
Your code seems to work fine, the "Signing in..." label appears after everything else disappear. I suggest you to just copy all your code from the .xaml.cs file and the .xaml file into a new project, but make sure you don't copy the first line"<Window x:Class="..."
because it could generate an error if the class name isn't the same in the new project.
For the xaml code I suggest you not think the same as you design windows forms applications. WPF has the layout system, which re-orientates or re-sizes its elements when re-sizing the window. So you should not specify exact numbers in the margin property as if they where coordinates. Create a grid, create rows or columns for each element and then just set the horizontal or vertical alignment or margins. Think different than the old windows forms way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With