SettingView.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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.Models.Lights;
  9. using TeamAAS_VP.ViewModels;
  10. namespace TeamAAS_VP.Views
  11. {
  12. /// <summary>
  13. /// Interaction logic for SettingView
  14. /// </summary>
  15. public partial class SettingView : UserControl
  16. {
  17. public SettingView()
  18. {
  19. InitializeComponent();
  20. }
  21. private void TreeView_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<object> e)
  22. {
  23. try
  24. {
  25. // 获取其 DataContext
  26. SettingViewModel viewModel = DataContext as SettingViewModel;
  27. if (e.NewValue is RobotInfo)
  28. {
  29. viewModel.SelectRobot = e.NewValue as RobotInfo;
  30. }
  31. else if (e.NewValue is FeederInfo)
  32. {
  33. viewModel.SelectFeeder = e.NewValue as FeederInfo;
  34. }
  35. else if (e.NewValue is CameraInfo)
  36. {
  37. viewModel.SelectCamera = e.NewValue as CameraInfo;
  38. }
  39. else if (e.NewValue is PlcInfo)
  40. {
  41. viewModel.SelectPlc = e.NewValue as PlcInfo;
  42. }
  43. else if (e.NewValue is LightControllerConfig)
  44. {
  45. viewModel.SelectLightController = e.NewValue as LightControllerConfig;
  46. }
  47. }
  48. catch (Exception)
  49. {
  50. }
  51. }
  52. }
  53. }