Recent articles


Toolbar not Visible in Xamarin forms?

Posted by seven.srikanth@gmail.com at 30 Nov 2017 in Tutorials


Usually, in Xamarin forms we will add below code to have a toolbar on top of the View.
 
<ContentPage.ToolbarItems >
<ToolbarItem Name="MenuItem1" Order="Primary" Icon="Microsoft.png" Text="Item 1" Priority="0" />
<ToolbarItem Name="MenuItem2" Order="Primary" Icon="Xamarin.png" Text="Item 2" Priority="1" />
</ContentPage.ToolbarItems>
But even after adding this code if you are unable to see the Toolbar, then you must need to enable the Navigation bar for the view. You can do this as shown below.
 
MainPage = new NavigationPage(new MainPage());
Here I enclosed the View call with in a NavigationPage and that does the trick. 
Screenshot of the View.
Hope this helps. 
Thanks.

Tags: enable NavigationBar; Unable to see ToolBar




How to open a New View on Button Click in Xamarin Forms?

Posted by seven.srikanth@gmail.com at 30 Nov 2017 in Tutorials


You need to use the below code for opening the new view. 
 Step 1: Add this code to the Main View or to the view where you need to place a button.
 
<Button x:Name="Btn_Book" Text="Proceed" Clicked="Btn_Book_Clicked" />
Step 2: Add this code to the page behind.
 
        async void Btn_Book_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushModalAsync(new anotherview());
        }
On Button click, anotherview.xaml will be opened. 
Hope this helps.

Tags: Button Click in Xamarin Forms




Picker in Xamarin Forms

Posted by seven.srikanth@gmail.com at 30 Nov 2017 in Tutorials


You can add the below code to your xamarin forms project to add a picker to your UI.
Steps:
1. Add this code to Xaml file.
 
<Picker x:Name="numberpicker" Title="Number of Cans" />
2. Add the below code to Init Method.
 
var numberslist = new List();
 
for (int i = 0; i < 100; i++)
{
       numberslist.Add(i);
}

numberpicker.ItemsSource = numberslist;
3. Run the Program.
Screenshot of Picker:
Thanks.

Tags: Picker; Xamarin Forms;