本文整理汇总了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());
}