Export (0) Print
Expand All

LayoutInformation Class

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 NotInheritable Class LayoutInformation

The LayoutInformation type exposes the following members.

Public methodStatic memberSupported by Silverlight for Windows PhoneGetLayoutClipReturns the visible region of the specified element.
Public methodStatic memberSupported by Silverlight for Windows PhoneGetLayoutExceptionElementReturns the element that was being processed by the layout system at the moment of an unhandled exception.
Public methodStatic memberSupported by Silverlight for Windows PhoneGetLayoutSlotReturns 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 Silverlight-based 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 Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    'Get Layout Slot of Rectangle 
    Dim r1 As Rect = LayoutInformation.GetLayoutSlot(rect1)
    Dim rg1 As New RectangleGeometry()
    rg1.Rect = r1
    Dim mypath As New Path()
    mypath.Data = rg1
    mypath.Stroke = New SolidColorBrush(Colors.Black)
    mypath.StrokeThickness = 4
End Sub

<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"/>


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

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

Community Additions

© 2015 Microsoft