/// <summary> /// Returns the visual parent. The visual parent is that contains the control in its list of controls /// </summary> /// <param name="control">The control to be searched</param> /// <returns></returns> public static IStateObject GetVisualParent(this IStateObject control) { var Parent = control.GetParentFromControl(); if (Parent == null || !(control is ControlViewModel)) return null; IStateObject value = null; var VisualParentDictionary = StaticContainer.Instance.Resolve<IViewManager>().GetVisualParentDictionary(); VisualParentDictionary.TryGetValue(control.UniqueID, out value); if (value != null) return value; IStateObject visualParent = null; if (Parent is IControlsContainer) { visualParent = FindVisualParent((IControlsContainer)Parent, (ControlViewModel)control, VisualParentDictionary); } return visualParent == null ? Parent : visualParent; }