How do you make a button hidden in C# in the Xamarin IDE in iOS? I know this may be an easy question for some people but I have tried multiple ways and I can't get it to work probably.
I've used the code:
button1.Hidden = True;
button2.Hidden = True;
button3.Hidden = True;
and I've placed this code in the viewDidLoad
section below
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
button1.Hidden = True;
button2.Hidden = True;
button3.Hidden = True;
// Perform any additional setup after loading the view, typically from a nib.
}
I've tried using button1.Visible = false;
but that doesn't work either. I've tried placing it in different places in my view controller file and I still can't get it to work. I've made sure that my buttons are corresponding with the names I am using in my file by naming them in the xamarin IDE. What I'm trying to do is make my buttons disappear and reappear at the click of a button but I can't even get them to initially disappear.
According to http://forums.xamarin.com/discussion/9317/how-to-hide-and-unhide-a-button
There is a very simple way to hide a button within Xamarin. Instead of using Button.Hide or Button.Hidden = true; You should go with
button.Visibility= ViewStates.Invisible;
This is essentially the same thing as Button.Hide(); or Button.Hidden = true; It borrows from WPF development somewhat, where instead of the methods you used which would come from WinForm development, it would look like..
button.Visibility = Visibility.Hidden;
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