Skip to content

Instantly share code, notes, and snippets.

@LucioMSP LucioMSP/LocationPage.xaml
Last active Nov 12, 2019

Embed
What would you like to do?
Example of how to implement Telerik SideDrawer control in Xamarin.Forms applications
<?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="TrkSideDrawer.Views.LocationPage"
xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives">
<ContentPage.ToolbarItems>
<ToolbarItem Activated="OnToolbarButtonClick"
Order="Primary"
Priority="0"
Text="IsOpen">
<ToolbarItem.Icon >
<OnPlatform x:TypeArguments="FileImageSource"
Android="hamburgerButtonIcon.png"
iOS="hamburgerButtonIcon.png" />
</ToolbarItem.Icon>
</ToolbarItem>
</ContentPage.ToolbarItems>
<Grid>
<telerikPrimitives:RadSideDrawer x:Name="drawer" DrawerLength="250" Margin="10,10">
<telerikPrimitives:RadSideDrawer.MainContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Text="Menu Location" />
<ListView x:Name="listview" Grid.Row="1" />
</Grid>
</telerikPrimitives:RadSideDrawer.MainContent>
<telerikPrimitives:RadSideDrawer.DrawerContent>
<Grid BackgroundColor="#826182" WidthRequest="220">
<ListView x:Name="drawerList" />
</Grid>
</telerikPrimitives:RadSideDrawer.DrawerContent>
</telerikPrimitives:RadSideDrawer>
</Grid>
</ContentPage>
using System;
using System.Linq;
using Xamarin.Forms;
using System.Collections.Generic;
using Telerik.XamarinForms.Primitives.SideDrawer;
namespace TrkSideDrawer.Views
{
public partial class LocationPage : ContentPage
{
public LocationPage()
{
InitializeComponent();
Title = "Location";
this.drawerList.ItemsSource = new List<string>() { "Home", "Contact", "Messages" };
var list = Enum.GetValues(typeof(SideDrawerLocation)).OfType<SideDrawerLocation>().ToList();
this.listview.ItemsSource = list;
Device.BeginInvokeOnMainThread(() => this.listview.SelectedItem = list[2]);
this.listview.ItemSelected += listview_ItemSelected;
}
void listview_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
if (e.SelectedItem != null)
{
drawer.DrawerLocation = (SideDrawerLocation)e.SelectedItem;
}
}
void OnToolbarButtonClick(object sender, EventArgs e)
{
drawer.IsOpen = !drawer.IsOpen;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.