Skip to content

Instantly share code, notes, and snippets.

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.TransitionsPage"
xmlns:telerik="clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
xmlns:telerikPrimitives="clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives">
<ContentPage.ToolbarItems>
<ToolbarItem Activated="OnToolbarButtonClick"
Order="Primary"
Priority="0"
Text="Open SideDrawer">
<ToolbarItem.Icon>
<OnPlatform x:TypeArguments="FileImageSource"
Android="hamburgerButtonIcon.png"
WinPhone="Assets/hamburgerButtonIcon.png"
iOS="hamburgerButtonIcon.png" />
</ToolbarItem.Icon>
</ToolbarItem>
</ContentPage.ToolbarItems>
<Grid>
<telerikPrimitives:RadSideDrawer x:Name="drawer" DrawerLength="250">
<telerikPrimitives:RadSideDrawer.MainContent>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Label Text="Transition Type:" Margin="10,10"/>
<Picker x:Name="picker"
Margin="10"
Grid.Row="1"
SelectedIndexChanged="picker_SelectedIndexChanged">
<Picker.Items>
<x:String>Push</x:String>
<x:String>Reveal</x:String>
<x:String>ReverseSlideOut</x:String>
<x:String>ScaleUp</x:String>
<x:String>SlideAlong</x:String>
<x:String>SlideInOnTop</x:String>
</Picker.Items>
</Picker>
<Label x:Name="descritpionLabel" Grid.Row="2" />
<Button x:Name="button1"
IsVisible="false"
Text="Open SideDrawer" />
</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 Xamarin.Forms;
using System.Collections.Generic;
using Telerik.XamarinForms.Primitives;
namespace TrkSideDrawer.Views
{
public partial class TransitionsPage : ContentPage
{
public TransitionsPage()
{
InitializeComponent();
Title = "Transitions";
picker.SelectedIndex = 0;
this.drawerList.ItemsSource = new List<string>() { "Home", "Contact", "Messages", "Trash" };
}
void OnToolbarButtonClick(object sender, EventArgs e)
{
drawer.IsOpen = !drawer.IsOpen;
}
void picker_SelectedIndexChanged(object sender, EventArgs e)
{
switch ((sender as Picker).SelectedIndex)
{
case 1: drawer.DrawerTransitionType = SideDrawerTransitionType.Reveal; break;
case 2: drawer.DrawerTransitionType = SideDrawerTransitionType.ReverseSlideOut; break;
case 3: drawer.DrawerTransitionType = SideDrawerTransitionType.ScaleUp; break;
case 4: drawer.DrawerTransitionType = SideDrawerTransitionType.SlideAlong; break;
case 5: drawer.DrawerTransitionType = SideDrawerTransitionType.SlideInOnTop; break;
default: drawer.DrawerTransitionType = SideDrawerTransitionType.Push; break;
}
}
}
}
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.