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


C# Border.GetRenderElement方法代码示例

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


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

示例1: BorderRenderTest

        public void BorderRenderTest()
        {
            Brush backgroundBrush = new LinearGradientBrush(30, Colors.Blue, Colors.Green);
            Brush borderBrush = new LinearGradientBrush(-30, Colors.Red, Colors.Blue);
            Thickness borderThickness = new Thickness(10, 20, 30, 40);

            Border border = new Border
            {
                Child = new FrameworkElement { Width = 200, Height = 100 },
                Background = backgroundBrush,
                BorderBrush = borderBrush,
                BorderThickness = borderThickness,
            };

            border.Measure(Size.Infinity);
            border.Arrange(new Rect(border.DesiredSize));

            IRenderElementFactory factory = TestRenderElementFactory.Default;

            border.GetRenderElement(factory);

            Assert.AreEqual(new Rect(240, 160), border.GetRenderElement(factory).Bounds);

            Assert.AreEqual(2, border.GetRenderElement(factory).Children.Count());

            IBorderRenderElement borderRenderElement = border.GetRenderElement(factory).Children.ElementAt(0) as IBorderRenderElement;
            Assert.IsNotNull(borderRenderElement);
            Assert.AreEqual(backgroundBrush, borderRenderElement.Background);
            Assert.AreEqual(borderBrush, borderRenderElement.BorderBrush);
            Assert.AreEqual(borderThickness, borderRenderElement.BorderThickness);
            Assert.AreEqual(new Rect(240, 160), borderRenderElement.Bounds);

            IVisualRenderElement visualRenderElement = border.GetRenderElement(factory).Children.ElementAt(1) as IVisualRenderElement;
            Assert.IsNotNull(visualRenderElement);
            Assert.AreEqual(new Rect(10, 20, 200, 100), visualRenderElement.Bounds);

            border.Child = null;
            Assert.AreEqual(1, border.GetRenderElement(factory).Children.Count());
        }
开发者ID:highzion,项目名称:Granular,代码行数:39,代码来源:BorderTest.cs


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