Determine the layout position of an element using the LayoutInformation : LayoutInformation « Windows Presentation Foundation « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » LayoutInformation 
16.54.1.Determine the layout position of an element using the LayoutInformation
<Window  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="layout_information.Window1"
    Title="LayoutInformation Sample">
    <Border Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top">
      <Grid Name="myGrid" Height="150">
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="250"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
          <RowDefinition />
          <RowDefinition />
          <RowDefinition />
        </Grid.RowDefinitions>
        <TextBlock Name="txt1" Margin="5" Grid.Column="0" Grid.Row="0">Hello World!</TextBlock>
        <Button Click="ShowLayoutSlot" Width="125" Height="25" Grid.Column="0" Grid.Row="1">Show Bounding Box</Button>

      </Grid>
  </Border>  
</Window>

//File:Window.xaml.vb
Imports System
Imports System.Windows
Imports System.Windows.Media
Imports System.Windows.Shapes
Imports System.Windows.Controls
Imports System.Windows.Controls.Primitives

Namespace layout_information
  Public Partial Class Window1
    Inherits Window
    Public Sub ShowLayoutSlot(sender As Object, e As System.Windows.RoutedEventArgs)
      Dim myRectangleGeometry As New RectangleGeometry()
      myRectangleGeometry.Rect = LayoutInformation.GetLayoutSlot(txt1)

      Dim myGeometryDrawing As New GeometryDrawing()
      Dim myPath As New Path()
      myPath.Data = myRectangleGeometry

      myPath.Stroke = Brushes.LightGoldenrodYellow
      myPath.StrokeThickness = 1
      Grid.SetColumn(myPath, 0)
      Grid.SetRow(myPath, 0)
      myGrid.Children.Add(myPath)


      Console.WriteLine(LayoutInformation.GetLayoutSlot(txt1).ToString())
    End Sub
  End Class
End Namespace
WPF Determine The Layout Position Of An Element Using The Layout Information
16.54.LayoutInformation
16.54.1.Determine the layout position of an element using the LayoutInformationDetermine the layout position of an element using the LayoutInformation
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.