Files
modernkeepass/ModernKeePass/Views/UserControls/HamburgerMenuUserControl.xaml.cs

131 lines
4.9 KiB
C#
Raw Normal View History

2018-07-26 12:01:49 +02:00
using System;
using System.Collections.Generic;
using System.Windows.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using ModernKeePass.Application.Common.Interfaces;
// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236
namespace ModernKeePass.Views.UserControls
{
public sealed partial class HamburgerMenuUserControl
{
public HamburgerMenuUserControl()
{
InitializeComponent();
}
public string HeaderLabel
{
get { return (string)GetValue(HeaderLabelProperty); }
set { SetValue(HeaderLabelProperty, value); }
}
public static readonly DependencyProperty HeaderLabelProperty =
DependencyProperty.Register(
nameof(HeaderLabel),
typeof(string),
typeof(HamburgerMenuUserControl),
new PropertyMetadata("Header", (o, args) => { }));
public string ButtonLabel
{
get { return (string)GetValue(ButtonLabelProperty); }
set { SetValue(ButtonLabelProperty, value); }
}
public static readonly DependencyProperty ButtonLabelProperty =
DependencyProperty.Register(
nameof(ButtonLabel),
typeof(string),
typeof(HamburgerMenuUserControl),
new PropertyMetadata("Button", (o, args) => { }));
public string DisplayMemberPath
{
get { return (string)GetValue(DisplayMemberPathProperty); }
set { SetValue(DisplayMemberPathProperty, value); }
}
public static readonly DependencyProperty DisplayMemberPathProperty =
DependencyProperty.Register(
nameof(DisplayMemberPath),
typeof(string),
typeof(HamburgerMenuUserControl),
new PropertyMetadata("Title", (o, args) => { }));
public Visibility IsButtonVisible
{
get { return (Visibility)GetValue(IsButtonVisibleProperty); }
set { SetValue(IsButtonVisibleProperty, value); }
}
public static readonly DependencyProperty IsButtonVisibleProperty =
DependencyProperty.Register(
nameof(IsButtonVisible),
typeof(Visibility),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(Visibility.Collapsed, (o, args) => { }));
public IEnumerable<IEntityVm> ItemsSource
{
get { return (IEnumerable<IEntityVm>)GetValue(ItemsSourceProperty); }
set { SetValue(ItemsSourceProperty, value); }
}
public static readonly DependencyProperty ItemsSourceProperty =
DependencyProperty.Register(
nameof(ItemsSource),
typeof(IEnumerable<IEntityVm>),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(new List<IEntityVm>(), (o, args) => { }));
public object SelectedItem
{
get { return GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
public static readonly DependencyProperty SelectedItemProperty =
DependencyProperty.Register(
nameof(SelectedItem),
typeof(object),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
2020-04-16 14:08:50 +02:00
public int SelectedIndex
{
get { return (int)GetValue(SelectedIndexProperty); }
set { SetValue(SelectedIndexProperty, value); }
}
public static readonly DependencyProperty SelectedIndexProperty =
DependencyProperty.Register(
nameof(SelectedIndex),
typeof(int),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(-1, (o, args) => { }));
public ICommand ActionButtonCommand
{
get { return (ICommand)GetValue(ActionButtonCommandProperty); }
set { SetValue(ActionButtonCommandProperty, value); }
}
public static readonly DependencyProperty ActionButtonCommandProperty =
DependencyProperty.Register(
nameof(ActionButtonCommand),
typeof(ICommand),
typeof(HamburgerMenuUserControl),
new PropertyMetadata(null, (o, args) => { }));
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
private void Selector_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
SelectionChanged?.Invoke(sender, e);
}
private void ToggleButton_OnUnchecked(object sender, RoutedEventArgs e)
{
var parent = Parent as FrameworkElement;
if (parent == null) return;
VisualStateManager.GoToState(this, parent.ActualWidth <= 640 ? "Hidden" : "Collapsed", true);
}
}
}