private async void AddExecuted(object sender, ExecutedRoutedEventArgs e) { if (NamespaceTree != null) { var vm = NamespaceTree.SelectedItem as ReferenceDescriptionViewModel; if (vm != null && (vm.IsVariable || vm.IsMethod)) { ModelItem item; switch (SubscriptionTabControl.SelectedIndex) { case 0: item = await Subscription.AddProperty(vm); if (item != null) { PropertiesGrid.Items.MoveCurrentTo(item); PropertiesGrid.ScrollIntoView(item); PropertiesGrid.Focus(); } break; case 1: item = await Subscription.AddCommand(vm); if (item != null) { CommandsGrid.Items.MoveCurrentTo(item); CommandsGrid.ScrollIntoView(item); CommandsGrid.Focus(); } break; case 2: item = await Subscription.AddDataSource(vm); if (item != null) { DataSourcesGrid.Items.MoveCurrentTo(item); DataSourcesGrid.ScrollIntoView(item); DataSourcesGrid.Focus(); } break; case 3: item = Subscription.AddMethod(vm); if (item != null) { MethodsGrid.Items.MoveCurrentTo(item); MethodsGrid.ScrollIntoView(item); MethodsGrid.Focus(); } break; } } e.Handled = true; } }
private async void OnCommandsGridDrop(object sender, DragEventArgs e) { var vm = e.Data.GetData(typeof(ReferenceDescriptionViewModel)) as ReferenceDescriptionViewModel; if (vm != null) { var item = await Subscription.AddCommand(vm); if (item != null) { CommandsGrid.Items.MoveCurrentTo(item); CommandsGrid.ScrollIntoView(item); CommandsGrid.Focus(); } } e.Handled = true; }