SettingView.xaml.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Prism.Commands;
  2. using Prism.Events;
  3. using Prism.Ioc;
  4. using Prism.Regions;
  5. using System;
  6. using System.Windows.Controls;
  7. using TeamAAS_VP.Models;
  8. using TeamAAS_VP.ViewModels;
  9. namespace TeamAAS_VP.Views
  10. {
  11. /// <summary>
  12. /// Interaction logic for SettingView
  13. /// </summary>
  14. public partial class SettingView : UserControl
  15. {
  16. public SettingView()
  17. {
  18. InitializeComponent();
  19. }
  20. private void TreeView_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<object> e)
  21. {
  22. try
  23. {
  24. // 获取其 DataContext
  25. SettingViewModel viewModel = DataContext as SettingViewModel;
  26. if (e.NewValue is RobotInfo)
  27. {
  28. viewModel.SelectRobot = e.NewValue as RobotInfo;
  29. }
  30. else if (e.NewValue is FeederInfo)
  31. {
  32. viewModel.SelectFeeder = e.NewValue as FeederInfo;
  33. }
  34. else if (e.NewValue is CameraInfo)
  35. {
  36. viewModel.SelectCamera = e.NewValue as CameraInfo;
  37. }
  38. else if (e.NewValue is PlcInfo)
  39. {
  40. viewModel.SelectPlc = e.NewValue as PlcInfo;
  41. }
  42. }
  43. catch (Exception)
  44. {
  45. }
  46. }
  47. }
  48. }