Last active
November 12, 2019 23:59
-
-
Save LucioMSP/9c22c60af6612d899676374355afc11b to your computer and use it in GitHub Desktop.
Example of how to implement Telerik SideDrawer control in Xamarin.Forms applications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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