Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a button hidden in C# Xamarin IDE iOS

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.

like image 423
parker88 Avatar asked Jul 25 '15 02:07

parker88


1 Answers

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;
like image 128
Jesse Glover Avatar answered Nov 15 '22 00:11

Jesse Glover