/// <summary> /// Using MouseLeftButtonUp to cause reselect on re-click, whereas SelectedItemChanged is only called when first selected /// </summary> /// <param name="sender">Originating UI element for this event</param> /// <param name="args">Mouse button event args</param> private void SelectOrReselect(object sender, MouseButtonEventArgs args) { TreeViewItem tvi = sender as TreeViewItem; if (tvi != null) { args.Handled = true; MainViewModel vm = DataContext as MainViewModel; TCRPlatformViewItem pvi = tvi.Header as TCRPlatformViewItem; if (pvi != null) { vm.CurrentPlatform = pvi; } else { TCRVersionViewItem vvi = tvi.Header as TCRVersionViewItem; if (vvi != null) { vm.CurrentTCRVersion = vvi; } else { TCRCategoryViewItem cvi = tvi.Header as TCRCategoryViewItem; if (cvi != null) { if (vm.CurrentTCRCategory != cvi) { vm.CurrentTCRCategory = cvi; cvi.IsExpanded = true; } else { cvi.IsExpanded = !cvi.IsExpanded; } } else { TCRViewItem tcrvi = tvi.Header as TCRViewItem; if (tcrvi != null) { vm.CurrentTCR = tcrvi; } } } } } }
/// <summary> /// Initializes a new instance of the <see cref="TCRVersionViewItem" /> class. /// </summary> /// <param name="version">DataModel TCRVersion to associate this ViewItem with</param> /// <param name="parent">Parent TCRPlatformViewItem</param> /// <param name="mainViewModel">A reference to the MainViewModel</param> public TCRVersionViewItem(DataModel.TCRVersion version, TCRPlatformViewItem parent, MainViewModel mainViewModel) { this.mainViewModel = mainViewModel; this.tcrVersion = version; this.TCRPlatformViewItem = parent; }