// Called when the UI object representing a SelectionStop gets clicked: // // * If this is a double-click and the SelectionStop can be expanded / collapsed, // expand / collapse the SelectionStop // private static void OnSelectionStopDoubleClickTargetMouseDown(object sender, MouseButtonEventArgs e) { DependencyObject target = e.OriginalSource as DependencyObject; if (target == null) { return; } if (e.ClickCount > 1) { FrameworkElement parentSelectionStopVisual = PropertySelection.FindParentSelectionStop <FrameworkElement>(target); if (parentSelectionStopVisual != null) { ISelectionStop parentSelectionStop = PropertySelection.GetSelectionStop(parentSelectionStopVisual); if (parentSelectionStop != null && parentSelectionStop.IsExpandable) { parentSelectionStop.IsExpanded = !parentSelectionStop.IsExpanded; } } } }
// Helper method that returns false if the given element is a collapsed SelectionStop, // true otherwise. // private static bool IsExpanded(DependencyObject element) { ISelectionStop selectionStop = PropertySelection.GetSelectionStop(element); return(selectionStop == null || selectionStop.IsExpanded); }