using Prism.Commands; using Prism.Events; using Prism.Ioc; using Prism.Regions; using System; using System.Windows.Controls; using TeamAAS_VP.Models; using TeamAAS_VP.Models.Feeder; using TeamAAS_VP.Models.Lights; using TeamAAS_VP.ViewModels; namespace TeamAAS_VP.Views { /// /// Interaction logic for SettingView /// public partial class SettingView : UserControl { public SettingView() { InitializeComponent(); } private void TreeView_SelectedItemChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs e) { try { // 获取其 DataContext SettingViewModel viewModel = DataContext as SettingViewModel; if (e.NewValue is RobotInfo) { viewModel.SelectRobot = e.NewValue as RobotInfo; } else if (e.NewValue is FeederInfo) { viewModel.SelectFeeder = e.NewValue as FeederInfo; } else if (e.NewValue is CameraInfo) { viewModel.SelectCamera = e.NewValue as CameraInfo; } else if (e.NewValue is PlcInfo) { viewModel.SelectPlc = e.NewValue as PlcInfo; } else if (e.NewValue is LightControllerConfig) { viewModel.SelectLightController = e.NewValue as LightControllerConfig; } else if (e.NewValue is ScrewFeederInfo) { viewModel.SelectScrewFeeder = e.NewValue as ScrewFeederInfo; } } catch (Exception) { } } } }