MenuButton.xaml.cs 1.7 KB

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