namespace DrawerExample
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
SfNavigationDrawer navigationDrawer = new SfNavigationDrawer();
navigationDrawer.Position = Position.Left;
navigationDrawer.Transition = Transition.Push;
navigationDrawer.TouchThreshold = 50;
navigationDrawer.Duration = 1000;
navigationDrawer.DrawerWidth = 150;
navigationDrawer.DrawerHeight = 100;
navigationDrawer.DrawerHeaderHeight = 100;
navigationDrawer.DrawerFooterHeight = 100;
Grid headerLayout = new Grid();
headerLayout.BackgroundColor = Color.FromHex("#1aa1d6");
Label header = new Label();
header.Text = "Header View";
header.FontSize = 14;
header.TextColor = Color.White;
header.HorizontalTextAlignment = TextAlignment.Center;
header.VerticalTextAlignment = TextAlignment.Center;
header.BackgroundColor = Color.FromHex("#1aa1d6");
headerLayout.Children.Add(header);
navigationDrawer.DrawerHeaderView = headerLayout;
ObservableCollection<String> list = new ObservableCollection<string>();
list.Add("RangeSlider");
list.Add("BusyIndicator");
list.Add("NumericUpDown");
StackLayout mainStack = new StackLayout();
mainStack.Orientation = StackOrientation.Vertical;
mainStack.HeightRequest = 500;
ListView listView = new ListView();
listView.WidthRequest = 200;
listView.VerticalOptions = LayoutOptions.FillAndExpand;
listView.ItemsSource = list;
mainStack.Children.Add(listView);
navigationDrawer.DrawerContentView = mainStack;
Button Btnmenu = new Button();
Btnmenu.Text = "Show Menu";
Btnmenu.HorizontalOptions = LayoutOptions.CenterAndExpand;
Btnmenu.VerticalOptions = LayoutOptions.CenterAndExpand;
Btnmenu.BackgroundColor = Color.FromHex("#1aa1d6");
StackLayout Stack = new StackLayout();
Stack.BackgroundColor = Color.White;
Stack.HeightRequest = 100;
Stack.HorizontalOptions = LayoutOptions.Center;
Stack.VerticalOptions = LayoutOptions.Center;
listView.ItemSelected += (object sender, SelectedItemChangedEventArgs e) =>
{
if (e.SelectedItem.ToString().Equals("RangeSlider"))
{
navigationDrawer.EnableSwipeGesture = true;
navigationDrawer.ContentView = new RangeSlider().Content;
}
if (e.SelectedItem.ToString().Equals("BusyIndicator"))
{
navigationDrawer.EnableSwipeGesture = true;
navigationDrawer.ContentView = new BusyIndicator().Content;
}
if (e.SelectedItem.ToString().Equals("NumericUpDown"))
{
navigationDrawer.EnableSwipeGesture = true;
navigationDrawer.ContentView = new NumericUpDown().Content;
}
};
Stack.Children.Add(Btnmenu);
navigationDrawer.ContentView = Stack;
StackLayout footerLayout = new StackLayout();
footerLayout.BackgroundColor = Color.FromHex("#1aa1d6");
Label footer = new Label();
footer.Text = "Footer View";
footer.FontSize = 14;
footer.TextColor = Color.White;
footer.HorizontalOptions = LayoutOptions.CenterAndExpand;
footer.VerticalOptions = LayoutOptions.CenterAndExpand;
footer.BackgroundColor = Color.FromHex("#1aa1d6");
footerLayout.Children.Add(footer);
navigationDrawer.DrawerFooterView = footerLayout;
this.Content = navigationDrawer;
Btnmenu.Clicked += (sender_, e3) =>
{
DependencyService.Get<IToggleDrawer>().ToggleDrawer();
};
}
}
}
|