LayoutInformation Class

LayoutInformation Class

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Defines methods that provide additional information about the layout of an element.


Namespace:  System.Windows.Controls.Primitives
Assembly:  System.Windows (in System.Windows.dll)

public static class LayoutInformation

The LayoutInformation type exposes the following members.

Public methodStatic memberGetLayoutClipReturns the visible region of the specified element.
Public methodStatic memberGetLayoutExceptionElementReturns the element that was being processed by the layout system at the moment of an unhandled exception.
Public methodStatic memberGetLayoutSlotReturns the layout slot, or bounding box, that contains the specified element.

The LayoutInformation class provides the GetLayoutSlot, GetLayoutClip, and GetLayoutExceptionElement methods to help you understand and debug the layout behavior of your Windows Phone application.

GetLayoutSlot and GetLayoutClip return information about an element's bounding box and visible region. GetLayoutExceptionElement helps you determine where an exception is coming from during layout.

The following example shows how to use GetLayoutSlot and draw the bounding box for the Rectangle.

private void Button_Click(object sender, RoutedEventArgs e)
    //Get Layout Slot of Rectangle
    Rect r1 = LayoutInformation.GetLayoutSlot(rect1);
    RectangleGeometry rg1 = new RectangleGeometry();
    rg1.Rect = r1;
    Path mypath = new Path();
    mypath.Data = rg1;
    mypath.Stroke = new SolidColorBrush(Colors.Black);
    mypath.StrokeThickness = 4;

<StackPanel x:Name="sp1" Grid.Row="0" Background="LightBlue" Height="100" Width="200" HorizontalAlignment="Left" VerticalAlignment="Top" >
    <Rectangle x:Name="rect1" Fill="Blue"  Width="100" Height="50" ></Rectangle>
<Button Content="Get Layout Slot" Grid.Row="1" Width="150" Height="50" Click="Button_Click" HorizontalAlignment="Left"/>

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

© 2017 Microsoft