I have a Stacklayout with switch control, when the switch values are true i have to show the layout and if the value changes to false i have to hide the layout. Based on some samples, i saw how to hide out a button but for hiding out a layout i can't find one. Can anyone suggest me how to do it in Xamarin.forms. Advance thanks guys for those helped me to solve the problem.
Switch.cs
void switchControl(object sender, ToggledEventArgs e)
{
if (e.Value == false)
{
StackLayout view = this.FindByName<StackLayout>("employee");
//hide the layout gone or invisible
}else{
//show the layout visible
}
}
From our discussion I have gathered that you want to show/hide a layout by toggling a
Switch
, inXAML
.For this we will be using data-binding.
Set your
StackLayout.IsVisible
property to bind to theSwitch.IsChecked
, like this:Also you noted that the layout has to be hidden by default. To implement this we will set the
Switch
to be unchecked by default like this: