Xamarin.Forms: ToolBarItems
Introduction
Xamarin is a platform to develop cross-platform and multi-platform apps (for example, Windows Phone, Android, iOS). In the Xamarin platform, the code sharing concept is used. In Xamarin Studio, Visual Studio is also available.
Universal Windows and select Extensions
- Windows Desktop Extension for the UWP. version:10.0.1439
- Windows Desktop Extension for the UWP. version:10.0.1058
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ToolBar.MainPage"
BackgroundColor="White">
<ContentPage.ToolbarItems>
<ToolbarItem Text="Add"
Priority="0"
Order="Secondary"
Clicked="ToolbarItem_Clicked"/>
<ToolbarItem Text="Cancel"
Priority="1"
Order="Secondary"
Clicked="ToolbarItem_Clicked"/>
</ContentPage.ToolbarItems>
<StackLayout>
<Label x:Name="MainLable"
HorizontalOptions="Center"
FontSize="30"
TextColor="Black"></Label>
</StackLayout>
</ContentPage>
MainPage.xaml.cs
using Xamarin.Forms;
namespace ToolBar
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void ToolbarItem_Clicked(object sender, EventArgs e)
{
MainLable.Text = "Your Selected Item Clicked";
}
}
}
App.cs
public App()
{
MainPage = new MainPage();
}