MainWindowMenu.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15. namespace NEIntelligentControl2.Views.MainWindow
  16. {
  17. /// <summary>
  18. /// 主窗口菜单页面
  19. /// </summary>
  20. public partial class MainWindowMenu : UserControl
  21. {
  22. // ------------事件--------------
  23. public static readonly RoutedEvent ItemClickEvent = EventManager.RegisterRoutedEvent("ItemClick", RoutingStrategy.Bubble, typeof(EventHandler<MenuItemRoutedEventArgs>), typeof(MainWindowMenu));
  24. public event RoutedEventHandler ItemClick { add { AddHandler(ItemClickEvent, value); } remove { RemoveHandler(ItemClickEvent, value); } }
  25. public MainWindowMenu()
  26. {
  27. InitializeComponent();
  28. }
  29. private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
  30. {
  31. MenuItemRoutedEventArgs mre = new MenuItemRoutedEventArgs(ItemClickEvent, this, ((Grid)sender).Tag as string);
  32. RaiseEvent(mre);
  33. }
  34. }
  35. public class MenuItemRoutedEventArgs : RoutedEventArgs
  36. {
  37. /// <summary>
  38. /// 点击信息
  39. /// </summary>
  40. public string Tag { get; set; }
  41. public MenuItemRoutedEventArgs(RoutedEvent routedEvent, object source, string tag) : base(routedEvent, source)
  42. {
  43. Tag = tag;
  44. }
  45. }
  46. }