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

 

Xamarin Forms : 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


Add caption


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#

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

Xamarin Forms - Change Colour of Navigation Bar (Page Title For Master-Detail Template)