MenuButton.xaml.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using PixiEditor.ViewModels;
  2. using System.Windows;
  3. using System.Windows.Controls;
  4. namespace PixiEditor.Views
  5. {
  6. /// <summary>
  7. /// Interaction logic for MenuButton.xaml
  8. /// </summary>
  9. public partial class MenuButton : UserControl
  10. {
  11. public static readonly DependencyProperty MenuButtonTextProperty =
  12. DependencyProperty.Register("Text", typeof(string), typeof(MenuButton),
  13. new UIPropertyMetadata(string.Empty));
  14. // Using a DependencyProperty as the backing store for Item. This enables animation, styling, binding, etc...
  15. public static readonly DependencyProperty ItemProperty =
  16. DependencyProperty.Register("Item", typeof(object), typeof(MenuButton), new PropertyMetadata(null));
  17. private readonly MenuButtonViewModel dc = new MenuButtonViewModel();
  18. public MenuButton()
  19. {
  20. InitializeComponent();
  21. DataContext = dc;
  22. }
  23. public string Text
  24. {
  25. get => (string)GetValue(MenuButtonTextProperty);
  26. set => SetValue(MenuButtonTextProperty, value);
  27. }
  28. public object Item
  29. {
  30. get => GetValue(ItemProperty);
  31. set => SetValue(ItemProperty, value);
  32. }
  33. protected override void OnIsKeyboardFocusWithinChanged(DependencyPropertyChangedEventArgs e)
  34. {
  35. dc.CloseListViewCommand.Execute(null);
  36. }
  37. }
  38. }