public static DocumentNodePath ResolveNodePathForTemplateWithinExistingStyle(SceneElement targetElement, PropertyReference targetPropertyReference)
        {
            DocumentNodePath documentNodePath = ControlStylingOperations.ProvideStyleOrTemplateNodePath(targetElement, targetPropertyReference);

            if (documentNodePath != null)
            {
                SceneView defaultView = targetElement.ViewModel.DefaultView;
                ICollection <IViewObject> instantiatedElements = defaultView.GetInstantiatedElements(documentNodePath);
                if (instantiatedElements.Count <= 0)
                {
                    return(ControlStylingOperations.FindTemplateWithinStyle(documentNodePath, targetElement, ControlElement.TemplateProperty, (IPropertyId)targetPropertyReference[0]));
                }
                foreach (IViewObject viewObject in (IEnumerable <IViewObject>)instantiatedElements)
                {
                    if (PlatformTypes.Control.IsAssignableFrom((ITypeId)viewObject.GetIType((ITypeResolver)targetElement.ProjectContext)))
                    {
                        object platformObject = viewObject.GetValue(targetElement.ProjectContext.ResolveProperty(ControlElement.TemplateProperty));
                        if (platformObject != null)
                        {
                            IViewObject      instance = targetElement.ViewModel.ProjectContext.Platform.ViewObjectFactory.Instantiate(platformObject);
                            DocumentNodePath correspondingNodePath = defaultView.GetCorrespondingNodePath(instance, true);
                            if (correspondingNodePath != null && ControlStylingOperations.ShouldSetEditingContextToNodePath(correspondingNodePath, targetElement, targetPropertyReference[0]))
                            {
                                return(correspondingNodePath);
                            }
                        }
                    }
                }
            }
            return((DocumentNodePath)null);
        }
 private static bool UpdateNavigationInfo(ControlStylingOperations.EditScope scope)
 {
     if (scope.NodePath == null)
     {
         PropertyReference targetPropertyReference = new PropertyReference(scope.TargetProperty);
         scope.NodePath = ControlStylingOperations.ProvideStyleOrTemplateNodePath(scope.TargetElement, targetPropertyReference);
     }
     if (scope.NodePath != null)
     {
         scope.Node        = scope.NodePath.Node;
         scope.EditInPlace = ControlStylingOperations.CanEditInPlace(scope.TargetElement, scope.TargetProperty, scope.NodePath);
     }
     return(scope.NodePath != null);
 }