LayoutInformation.GetLayoutSlot(FrameworkElement) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回表示为子元素保留的布局分区的 Rect。
public:
static System::Windows::Rect GetLayoutSlot(System::Windows::FrameworkElement ^ element);
public static System.Windows.Rect GetLayoutSlot (System.Windows.FrameworkElement element);
static member GetLayoutSlot : System.Windows.FrameworkElement -> System.Windows.Rect
Public Shared Function GetLayoutSlot (element As FrameworkElement) As Rect
参数
- element
- FrameworkElement
需要其布局槽的 FrameworkElement。
返回
表示元素的布局槽的 Rect。
示例
以下示例演示如何使用 GetLayoutSlot 方法将 的 FrameworkElement 边界框转换为 GeometryDrawing。
private void getLayoutSlot1(object sender, System.Windows.RoutedEventArgs e)
{
RectangleGeometry myRectangleGeometry = new RectangleGeometry();
myRectangleGeometry.Rect = LayoutInformation.GetLayoutSlot(txt1);
Path myPath = new Path();
myPath.Data = myRectangleGeometry;
myPath.Stroke = Brushes.LightGoldenrodYellow;
myPath.StrokeThickness = 5;
Grid.SetColumn(myPath, 0);
Grid.SetRow(myPath, 0);
myGrid.Children.Add(myPath);
txt2.Text = "LayoutSlot is equal to " + LayoutInformation.GetLayoutSlot(txt1).ToString();
}
Private Sub getLayoutSlot1(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim myRectangleGeometry As New RectangleGeometry
myRectangleGeometry.Rect = LayoutInformation.GetLayoutSlot(txt1)
Dim myPath As New Path
myPath.Data = myRectangleGeometry
myPath.Stroke = Brushes.LightGoldenrodYellow
myPath.StrokeThickness = 5
Grid.SetColumn(myPath, 0)
Grid.SetRow(myPath, 0)
myGrid.Children.Add(myPath)
txt2.Text = "LayoutSlot is equal to " + LayoutInformation.GetLayoutSlot(txt1).ToString()
End Sub