当前位置: 首页>>代码示例>>C#>>正文


C# DependencyObject.GetVisualAncestors方法代码示例

本文整理汇总了C#中System.Windows.DependencyObject.GetVisualAncestors方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.GetVisualAncestors方法的具体用法?C# DependencyObject.GetVisualAncestors怎么用?C# DependencyObject.GetVisualAncestors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.DependencyObject的用法示例。


在下文中一共展示了DependencyObject.GetVisualAncestors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsAncestorOf

        /// <summary>
        /// Determines whether the visual object is an ancestor of the descendant visual object.
        /// </summary>
        /// <param name="element">The <see cref="UIElement"/>.</param>
        /// <param name="descendant">The <see cref="DependencyObject"/>.</param>
        /// <returns>
        /// <see langword="true"/> if the <paramref name="element"/> is an ancestor of
        /// <paramref name="descendant"/>; otherwise, <see langword="false"/>.
        /// </returns>
        public static bool IsAncestorOf(this UIElement element, DependencyObject descendant)
        {
            if (element == null || descendant == null)
                return false;

            if (element == descendant)
                return true;

            return descendant.GetVisualAncestors().Contains(element);
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:19,代码来源:WindowsHelper.SL.cs

示例2: OnVisibleChanged

        private static void OnVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != e.OldValue) {
                var appbar = ((BindableAppBar)d).ApplicationBar;

                appbar.IsVisible = (bool)e.NewValue;

                var page = d.GetVisualAncestors().OfType<PhoneApplicationPage>().FirstOrDefault();

                // Swapping bars?
                if (page != null && appbar.IsVisible && page.ApplicationBar != appbar) {
                    page.ApplicationBar = appbar;

                    Log.Info("Set appbar as foreground appbar");
                }
            }
        }
开发者ID:jagui,项目名称:CaliburnBindableAppBar,代码行数:17,代码来源:CustomAppBar.cs

示例3: OnYAxisChanged

        private static void OnYAxisChanged(DependencyObject element, DependencyPropertyChangedEventArgs eventArgs)
        {
            if (eventArgs.OldValue == eventArgs.NewValue)
                return;

            var chartPanel = element.GetVisualAncestors()
                                    .OfType<ChartPanel>()
                                    .FirstOrDefault();

            if (element is IChartElement)
            {
                var chartElement = (IChartElement)element;
                var yAxis = (Axis)eventArgs.NewValue;

                // Synchronize the attached dependency property ChartPanel.XAxis with 
                // the dependency property ChartElement.XAxis.
                chartElement.YAxis = yAxis;
            }
            else if (element is UIElement)
            {
                // Size of the element might have changed.
                // --> Re-measure element.
                var uiElement = (UIElement)element;
                uiElement.InvalidateMeasure();

                // Reposition element in ChartPanel.
                if (chartPanel != null)
                    chartPanel.InvalidateArrange();
            }

            if (chartPanel != null)
                chartPanel.DetectAxes();
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:33,代码来源:ChartPanel_AttachedProperties.cs

示例4: OnViewportWidthChanged

 private static void OnViewportWidthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     d.GetVisualAncestors().OfType<DataGrid>().Last().OnViewportWidthChanged(e);
 }
开发者ID:guidgets,项目名称:XamlGrid,代码行数:4,代码来源:DataGrid.cs

示例5: OnPositioningChanged

        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        private static void OnPositioningChanged(DependencyObject element, DependencyPropertyChangedEventArgs eventArgs)
        {
            var chartPanel = element.GetVisualAncestors().OfType<ChartPanel>().FirstOrDefault();
            if (chartPanel != null)
                chartPanel.InvalidateArrange();
        }
开发者ID:Zolniu,项目名称:DigitalRune,代码行数:10,代码来源:ChartPanel_AttachedProperties.cs


注:本文中的System.Windows.DependencyObject.GetVisualAncestors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。