Bagikan melalui


LayoutInformation Kelas

Definisi

Menentukan metode yang memberikan informasi tambahan tentang tata letak elemen.

public ref class LayoutInformation sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 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(Microsoft.UI.Xaml.WinUIContract), 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
Warisan
Object Platform::Object IInspectable LayoutInformation
Atribut

Contoh

Contoh berikut menunjukkan cara menggunakan GetLayoutSlot dan menggambar kotak pembatas untuk Persegi Panjang.

<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);
}

Metode

GetAvailableSize(UIElement)

Mengembalikan nilai Ukuran yang terakhir digunakan untuk mengukur elemen yang ditentukan.

GetLayoutExceptionElement(Object)

Mengembalikan elemen yang sedang diproses oleh sistem tata letak pada saat pengecualian yang tidak tertangani.

GetLayoutSlot(FrameworkElement)

Mengembalikan slot tata letak, atau kotak pembatas, yang berisi elemen yang ditentukan.

Berlaku untuk