Xamarin Forms - Find Control of MainPage from any Class or Page

Find Control of MainPage from any Class or Page


E.g. If you have Menu on MainPage and you need to apply Rights from User Validation Class. How do you access Control / Button of Menu from the class


Code : 
Button button = null;
button = (Button)App.Current.MainPage.FindByName("btnStkRpt_CustCsgSumm");
if (button != null)
{
  button.IsEnabled = true;
  button.IsVisible = true;
}
 

Note : This will find control on mainpage (Startup Page or Current Main Page)

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)