/// <summary> /// Handles click /// </summary> /// <param name="args"></param> protected virtual void OnClick(RoutedEventArgs args) { // Close Backstage if (IsDefinitive) { BackstageButton ribbon = FindOwnerRibbon(); if (ribbon != null) { ribbon.IsOpen = false; } } }
/// <summary> /// Finds owner ribbon /// </summary> /// <returns>Owner ribbon</returns> protected BackstageButton FindOwnerRibbon() { DependencyObject obj = LogicalTreeHelper.GetParent(this); while (obj != null) { BackstageButton ribbon = obj as BackstageButton; if (ribbon != null) { return(ribbon); } obj = LogicalTreeHelper.GetParent(obj); } return(null); }