I’d like to be able to show or hide a tableview with the click of a button. I know how to set the visibility of the view, just not how to toggle back and forth.
Edit: Another option that seems to work for anyone else needing to do this:
showHide.Click += delegate
{
if (otherEquip.Visibility == ViewStates.Visible)
{
otherEquip.Visibility = ViewStates.Invisible;
}
else
{
otherEquip.Visibility = ViewStates.Visible;
}
};
There is no built in toggle method that I know of. There are also three visibility states a view can have – visible, invisible, gone – so “toggling” doesn’t really work there. If you wanted to swap between invisible and visible, for example, you could do something like:
Or if you wanted to make it more reusable you could put it in an extension method:
and then call on the view: