LayoutInformation LayoutInformation LayoutInformation LayoutInformation Class

Definition

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

public : sealed class LayoutInformation
struct winrt::Windows::UI::Xaml::Controls::Primitives::LayoutInformation
public sealed class LayoutInformation
Public NotInheritable Class LayoutInformation
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

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

<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"/>
private void Button_Click(object sender, RoutedEventArgs e)
{
    //Get Layout Slot of Rectangle
    Windows.Foundation.Rect r1 = LayoutInformation.GetLayoutSlot(rect1);
    RectangleGeometry rg1 = new RectangleGeometry();
    rg1.Rect = r1;
    Path mypath = new Path();
    mypath.Data = rg1;
    mypath.Stroke = new SolidColorBrush(Colors.Red);
    mypath.StrokeThickness = 4;
    LayoutRoot.Children.Add(mypath);
}
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
    LayoutRoot.Children.Add(mypath)
End Sub

Remarks

Version history

Windows version SDK version Value added
1709 16299 GetAvailableSize

Methods

GetAvailableSize(UIElement) GetAvailableSize(UIElement) GetAvailableSize(UIElement) GetAvailableSize(UIElement)

Returns the Size value that was most recently used to measure the specified element.

GetLayoutExceptionElement(Object) GetLayoutExceptionElement(Object) GetLayoutExceptionElement(Object) GetLayoutExceptionElement(Object)

Returns the element that was being processed by the layout system at the moment of an unhandled exception.

GetLayoutSlot(FrameworkElement) GetLayoutSlot(FrameworkElement) GetLayoutSlot(FrameworkElement) GetLayoutSlot(FrameworkElement)

Returns the layout slot, or bounding box, that contains the specified element.