Posts

Showing posts from July, 2020

Xamarin Forms - Icon/Image in Toolbar of Navigation Page

Image
Icon/Image in Toolbar of Navigation Page  Code : Page XAML < ContentPage.ToolbarItems >          < ToolbarItem  Name = "imgrcLogo"  Icon = "RCLogo.png"  Priority = "0"  Order = "Primary"  />          < ToolbarItem    x : Name = "userInfo"    Priority = "0"  Order = "Primary"     />      </ ContentPage.ToolbarItems > Logo file is Places in Resouce Directory of Andriod project

Xamarin Forms - Close the Application in Andriod and IOS

Close the Application in Andriod and IOS if (Device.RuntimePlatform == Device.iOS) {        Thread.CurrentThread.Abort();  } else if (Device.RuntimePlatform == Device.Android) {     Android.OS.Process.KillProcess(Android.OS.Process.MyPid()); }

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

Image
Change All Toolbar Bar Color (Toolbar is Actually Navigation Page) Navigation Page Title Colour can be Changed using Style Type in App.XAML Navigation Page Appears in case of Master-Details Template Type We need to create Global Style Type in APP.xaml Code :  <Style TargetType="NavigationPage">                           <Setter Property="BarBackgroundColor" Value="Color.LightGray"/> </Style>

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Image
How to Show PopUp Page In Xamarin Forms Step 1 First, we need to add the Third Page Plugin to achieve the same. [ Rg.Plugins.Popup ] Go to Manage Nuget Packages - > Search for Rg.Plugins.Popup Once the plugin is installed in the Project We need to configure same in Android and IOS Projects In Android   - Go to MainActivity.cs Code:     Rg.Plugins.Popup. Popup .Init( this , savedInstanceState); In IOS –   Go to   - AppDelegate.cs Code : Rg.Plugins.Popup. Popup .Init(); Now Back to Main Project (PCL) Step – 1 :   Add Page in Project Once Added Page Change the Tag of Page Default Page has Content page as Tag which needs to be replaced with PopUpPage Class  :  Default Page:- Class < ContentPage  xmlns ="http://xamarin.com/schemas/2014/forms" Change To < pages : PopupPage  xmlns ="http://xamarin.com/schemas/2014/forms" This is how it should Lo...

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

Image
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)

Xamarin Forms - How to Set Login page at Startup and later change to Home Page Or Change Startup Page

Image
Xamarin Forms How to Set Login page at Startup and later change to Home Page as Current.MainPage in Xamarin Forms Step   -1 In-App.XaML.cs Change MainPage Object from MainPage to PageLogin. This will change the Startup page from Main to Page Login Code :   Application .Current.MainPage =  new   PageLogin (); Step 2 Page Login :   In Button of Login (Validation == True) Code : Application .Current.MainPage =  new   MainPage (); Note: Once you have Validated User successfully change back to MainPage