private NodeViewModel FindParentNodeViewModel(FrameworkElement obj) { try { if (obj.GetType() == typeof(AdornedControl.AdornedControl)) { AdornedControl.AdornedControl adornerParent = (AdornedControl.AdornedControl)obj; if (adornerParent.DataContext.GetType() == typeof(NodeViewModel)) { return(((AdornedControl.AdornedControl)obj).DataContext as NodeViewModel); } else { return(null); // we found the adorner parent object, but the context wasn't right... why loop forever when we can just return nothing now } } else { return(FindParentNodeViewModel((FrameworkElement)obj.Parent)); } } catch (Exception e) { //something (understandably) went horribly wrong... //Likely a child wasnt a framework element or something return(null); } }
public static void SetAdornerToMainViewModel(AdornedControl.AdornedControl control) { MainStatic.LoadingAdorner = control; }