LayoutInformation 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义提供有关元素布局的其他信息的方法。
public ref class LayoutInformation sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class LayoutInformation final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class LayoutInformation
Public NotInheritable Class LayoutInformation
- 继承
- 属性
Windows 要求
设备系列 |
Windows 10 (在 10.0.10240.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v1.0 中引入)
|
示例
以下示例演示如何使用 GetLayoutSlot 并绘制 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
注解
版本历史记录
Windows 版本 | SDK 版本 | 增值 |
---|---|---|
1709 | 16299 | GetAvailableSize |
方法
GetAvailableSize(UIElement) |
返回最近用于度量指定元素的 Size 值。 |
GetLayoutExceptionElement(Object) |
返回在出现未经处理的异常时布局系统正在处理的元素。 |
GetLayoutSlot(FrameworkElement) |
返回包含指定元素的布局槽或边界框。 |