コード例 #1
0
        internal static FrameworkObject GetContainingFrameworkElement(DependencyObject current)
        {
            var fo = new FrameworkObject(current);

            while (!fo.IsValid && fo.DependencyObject != null)
            {
                // The current object is neither a FrameworkElement nor a
                // FrameworkContentElement.  We will now walk the "core"
                // tree looking for one.
                Visual         visual;
                Visual3D       visual3D;
                ContentElement ce;

                if ((visual = fo.DependencyObject as Visual) != null)
                {
                    fo.Reset(VisualTreeHelper.GetParent(visual));
                }
                else if ((ce = fo.DependencyObject as ContentElement) != null)
                {
                    fo.Reset(ContentOperations.GetParent(ce));
                }
                else if ((visual3D = fo.DependencyObject as Visual3D) != null)
                {
                    fo.Reset(VisualTreeHelper.GetParent(visual3D));
                }
                else
                {
                    // The parent could be an application.
                    fo.Reset(null);
                }
            }

            return(fo);
        }
コード例 #2
0
        //// internal bool ThisHasLoadedChangeEventHandler
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.ThisHasLoadedChangeEventHandler;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.ThisHasLoadedChangeEventHandler;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        //// }

        //// internal bool SubtreeHasLoadedChangeHandler
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.SubtreeHasLoadedChangeHandler;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.SubtreeHasLoadedChangeHandler;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.SubtreeHasLoadedChangeHandler = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.SubtreeHasLoadedChangeHandler = value;
        ////        }
        ////    }
        //// }

        //// internal InheritanceBehavior InheritanceBehavior
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.InheritanceBehavior;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.InheritanceBehavior;
        ////        }
        ////        else
        ////        {
        ////            return InheritanceBehavior.Default;
        ////        }
        ////    }
        //// }

        //// internal bool StoresParentTemplateValues
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.StoresParentTemplateValues;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.StoresParentTemplateValues;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.StoresParentTemplateValues = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.StoresParentTemplateValues = value;
        ////        }
        ////    }
        //// }

        //// internal bool HasResourceReference
        //// {
        ////    /* not used (yet)
        ////    get
        ////    {
        ////        if (IsFE)
        ////        {
        ////            return _fe.HasResourceReference;
        ////        }
        ////        else if (IsFCE)
        ////        {
        ////            return _fce.HasResourceReference;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    */
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.HasResourceReference = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.HasResourceReference = value;
        ////        }
        ////    }
        //// }

        /* not used (yet)
         * internal bool HasStyleChanged
         * {
         *  get
         *  {
         *      if (IsFE)
         *      {
         *          return _fe.HasStyleChanged;
         *      }
         *      else if (IsFCE)
         *      {
         *          return _fce.HasStyleChanged;
         *      }
         *      else
         *      {
         *          return false;
         *      }
         *  }
         *  set
         *  {
         *      if (IsFE)
         *      {
         *          _fe.HasStyleChanged = value;
         *      }
         *      else if (IsFCE)
         *      {
         *          _fce.HasStyleChanged = value;
         *      }
         *  }
         * }
         */

        //// internal bool HasTemplateChanged
        //// {
        ////    /* not used (yet)
        ////    get
        ////    {
        ////        if (IsFE)
        ////        {
        ////            return _fe.HasTemplateChanged;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    */
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.HasTemplateChanged = value;
        ////        }
        ////    }
        //// }

        //// Says if there are any implicit styles in the ancestry
        //// internal bool ShouldLookupImplicitStyles
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.ShouldLookupImplicitStyles;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.ShouldLookupImplicitStyles;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.ShouldLookupImplicitStyles = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.ShouldLookupImplicitStyles = value;
        ////        }
        ////    }
        //// }

        internal static bool IsEffectiveAncestor(DependencyObject d1, DependencyObject d2)
        {
            for (var fo = new FrameworkObject(d2);
                 fo.DependencyObject != null;
                 fo.Reset(fo.EffectiveParent))
            {
                if (ReferenceEquals(fo.DependencyObject, d1))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
        internal static FrameworkObject GetContainingFrameworkElement(DependencyObject current)
        {
            FrameworkObject fo = new FrameworkObject(current);

            while (!fo.IsValid && fo.DependencyObject != null)
            {
                // The current object is neither a FrameworkElement nor a
                // FrameworkContentElement.  We will now walk the "core"
                // tree looking for one.
                Visual visual;
                Visual3D visual3D;
                ContentElement ce;

                if ((visual = fo.DependencyObject as Visual) != null)
                {
                    fo.Reset(VisualTreeHelper.GetParent(visual));
                }
                else if ((ce = fo.DependencyObject as ContentElement) != null)
                {
                    fo.Reset(ContentOperations.GetParent(ce));
                }
                else if ((visual3D = fo.DependencyObject as Visual3D) != null)
                {
                    fo.Reset(VisualTreeHelper.GetParent(visual3D));
                }
                else
                {
                    // The parent could be an application.
                    fo.Reset(null);
                }
            }

            return fo;
        }
コード例 #4
0
        //// internal bool ThisHasLoadedChangeEventHandler
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.ThisHasLoadedChangeEventHandler;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.ThisHasLoadedChangeEventHandler;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        //// }

        //// internal bool SubtreeHasLoadedChangeHandler
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.SubtreeHasLoadedChangeHandler;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.SubtreeHasLoadedChangeHandler;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.SubtreeHasLoadedChangeHandler = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.SubtreeHasLoadedChangeHandler = value;
        ////        }
        ////    }
        //// }

        //// internal InheritanceBehavior InheritanceBehavior
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.InheritanceBehavior;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.InheritanceBehavior;
        ////        }
        ////        else
        ////        {
        ////            return InheritanceBehavior.Default;
        ////        }
        ////    }
        //// }

        //// internal bool StoresParentTemplateValues
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.StoresParentTemplateValues;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.StoresParentTemplateValues;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.StoresParentTemplateValues = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.StoresParentTemplateValues = value;
        ////        }
        ////    }
        //// }

        //// internal bool HasResourceReference
        //// {
        ////    /* not used (yet)
        ////    get
        ////    {
        ////        if (IsFE)
        ////        {
        ////            return _fe.HasResourceReference;
        ////        }
        ////        else if (IsFCE)
        ////        {
        ////            return _fce.HasResourceReference;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    */
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.HasResourceReference = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.HasResourceReference = value;
        ////        }
        ////    }
        //// }

        /* not used (yet)
        internal bool HasStyleChanged
        {
            get
            {
                if (IsFE)
                {
                    return _fe.HasStyleChanged;
                }
                else if (IsFCE)
                {
                    return _fce.HasStyleChanged;
                }
                else
                {
                    return false;
                }
            }
            set
            {
                if (IsFE)
                {
                    _fe.HasStyleChanged = value;
                }
                else if (IsFCE)
                {
                    _fce.HasStyleChanged = value;
                }
            }
        }
        */

        //// internal bool HasTemplateChanged
        //// {
        ////    /* not used (yet)
        ////    get
        ////    {
        ////        if (IsFE)
        ////        {
        ////            return _fe.HasTemplateChanged;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    */
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.HasTemplateChanged = value;
        ////        }
        ////    }
        //// }

        //// Says if there are any implicit styles in the ancestry
        //// internal bool ShouldLookupImplicitStyles
        //// {
        ////    get
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            return this._fe.ShouldLookupImplicitStyles;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            return this._fce.ShouldLookupImplicitStyles;
        ////        }
        ////        else
        ////        {
        ////            return false;
        ////        }
        ////    }
        ////    set
        ////    {
        ////        if (this.IsFE)
        ////        {
        ////            this._fe.ShouldLookupImplicitStyles = value;
        ////        }
        ////        else if (this.IsFCE)
        ////        {
        ////            this._fce.ShouldLookupImplicitStyles = value;
        ////        }
        ////    }
        //// }

        internal static bool IsEffectiveAncestor(DependencyObject d1, DependencyObject d2)
        {
            for (FrameworkObject fo = new FrameworkObject(d2);
                fo.DependencyObject != null;
                fo.Reset(fo.EffectiveParent))
            {
                if (ReferenceEquals(fo.DependencyObject, d1))
                {
                    return true;
                }
            }

            return false;
        }