Пример #1
0
 /// <summary>
 /// Returns true if the child is left aligned with Panel or has no horizontal alignment instructions
 /// </summary>
 private bool IsAlignLeftWithPanel(IFrameworkElement child)
 {
     return(RelativePanel.GetAlignLeftWithPanel(child) ||
            !(
                RelativePanel.GetAlignRightWithPanel(child) ||
                RelativePanel.GetAlignHorizontalCenterWithPanel(child) ||
                RelativePanel.GetAlignLeftWith(child) != null ||
                RelativePanel.GetAlignRightWith(child) != null ||
                RelativePanel.GetRightOf(child) != null ||
                RelativePanel.GetLeftOf(child) != null
                ));
 }
Пример #2
0
        /// <summary>
        /// Gets all the direct dependencies of a FrameworkElement (based on the set AttachedProperties)
        /// </summary>
        private Dependency[] GetDependencies(UIElement child, IFrameworkElement[] allChildren)
        {
            var dependencies = new List <Dependency>(Dependency.DependencyTypeCount);

            IFrameworkElement element;

            element = GetChild(RelativePanel.GetAbove(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.Above));
            }

            element = GetChild(RelativePanel.GetBelow(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.Below));
            }

            element = GetChild(RelativePanel.GetLeftOf(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.LeftOf));
            }

            element = GetChild(RelativePanel.GetRightOf(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.RightOf));
            }

            element = GetChild(RelativePanel.GetAlignBottomWith(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.AlignBottomWith));
            }

            element = GetChild(RelativePanel.GetAlignHorizontalCenterWith(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.AlignHorizontalCenterWith));
            }

            element = GetChild(RelativePanel.GetAlignLeftWith(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.AlignLeftWith));
            }

            element = GetChild(RelativePanel.GetAlignRightWith(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.AlignRightWith));
            }

            element = GetChild(RelativePanel.GetAlignTopWith(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.AlignTopWith));
            }

            element = GetChild(RelativePanel.GetAlignVerticalCenterWith(child), allChildren);
            if (element != null)
            {
                dependencies.Add(new Dependency(element, DependencyType.AlignVerticalCenterWith));
            }

            return(dependencies.ToArray());
        }