csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.1 KiB
65 lines
2.1 KiB
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
|
|
namespace ControlCatalog.Pages
|
|
{
|
|
public partial class DrawerPageFirstLookPage : UserControl
|
|
{
|
|
public DrawerPageFirstLookPage()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override void OnLoaded(RoutedEventArgs e)
|
|
{
|
|
base.OnLoaded(e);
|
|
DemoDrawer.Opened += OnDrawerStatusChanged;
|
|
DemoDrawer.Closed += OnDrawerStatusChanged;
|
|
}
|
|
|
|
protected override void OnUnloaded(RoutedEventArgs e)
|
|
{
|
|
base.OnUnloaded(e);
|
|
DemoDrawer.Opened -= OnDrawerStatusChanged;
|
|
DemoDrawer.Closed -= OnDrawerStatusChanged;
|
|
}
|
|
|
|
private void OnDrawerStatusChanged(object? sender, System.EventArgs e) => UpdateStatus();
|
|
|
|
private void OnToggleDrawer(object? sender, RoutedEventArgs e)
|
|
{
|
|
DemoDrawer.IsOpen = !DemoDrawer.IsOpen;
|
|
}
|
|
|
|
private void OnGestureChanged(object? sender, RoutedEventArgs e)
|
|
{
|
|
DemoDrawer.IsGestureEnabled = GestureCheck.IsChecked == true;
|
|
}
|
|
|
|
private void OnMenuSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
|
{
|
|
if (DrawerMenu.SelectedItem is ListBoxItem item)
|
|
{
|
|
DemoDrawer.Content = new ContentPage
|
|
{
|
|
Header = item.Content?.ToString(),
|
|
Content = new TextBlock
|
|
{
|
|
Text = $"{item.Content} page content",
|
|
FontSize = 16,
|
|
HorizontalAlignment = Avalonia.Layout.HorizontalAlignment.Center,
|
|
VerticalAlignment = Avalonia.Layout.VerticalAlignment.Center
|
|
},
|
|
HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Stretch,
|
|
VerticalContentAlignment = Avalonia.Layout.VerticalAlignment.Stretch
|
|
};
|
|
DemoDrawer.IsOpen = false;
|
|
}
|
|
}
|
|
|
|
private void UpdateStatus()
|
|
{
|
|
StatusText.Text = $"Drawer: {(DemoDrawer.IsOpen ? "Open" : "Closed")}";
|
|
}
|
|
}
|
|
}
|
|
|