MenuButton.xaml.cs 1.4 KB

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