Export (0) Print
Expand All

LayoutInformation Class

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

System.Object
  System.Windows.Controls.Primitives.LayoutInformation

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

public static class LayoutInformation

The LayoutInformation type exposes the following members.

  NameDescription
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.
Top

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 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;
    LayoutRoot.Children.Add(mypath);
}



<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>
</StackPanel>
<Button Content="Get Layout Slot" Grid.Row="1" Width="150" Height="50" Click="Button_Click" HorizontalAlignment="Left"/>


Silverlight

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

ADD
Show:
© 2014 Microsoft