Put Button onto a Grid : Grid « Windows Presentation Foundation « VB.Net Tutorial






<Window x:Class="MyFirstWPFApp.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MyFirstWPFApp" Height="336" Width="343">
    <Grid>
      <Button Click="MyClickEvent"
         VerticalAlignment="Top"
         HorizontalAlignment="Left"
         Grid.Column="0"
         Grid.ColumnSpan="1"
         Grid.Row="0"
         Grid.RowSpan="1"
         Margin="43,61,0,0"
         Width="75"
         Height="23"
         Name="btnGo">Go</Button>
    </Grid>  
</Window>

//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes


Namespace MyFirstWPFApp
  Public Partial Class Window1
    Inherits System.Windows.Window

    Private Sub MyClickEvent(sender As Object, e As RoutedEventArgs)
      MessageBox.Show("Elexzandreia the beautiful!", "Message", MessageBoxButton.OK, MessageBoxImage.Hand)
    End Sub

    Public Sub New()
      InitializeComponent()
    End Sub

  End Class
End Namespace
WPF Put Button Onto A Grid








16.34.Grid
16.34.1.The first row of a gridThe first row of a grid
16.34.2.Positioning elements using a GridPositioning elements using a Grid
16.34.3.Layout within a button using GridLayout within a button using Grid
16.34.4.Label in a GridLabel in a Grid
16.34.5.Display Content in Resizable Split PanelDisplay Content in Resizable Split Panel
16.34.6.Place more than two object to one cellPlace more than two object to one cell
16.34.7.Add StackPanel to Row 0Add StackPanel to Row 0
16.34.8.Using the attached properties of GridUsing the attached properties of Grid
16.34.9.Two columns and three rows columnsTwo columns and three rows columns
16.34.10.Fixed column widthFixed column width
16.34.11.Grid with row and column definition and place buttons to grid cellsGrid with row and column definition and place buttons to grid cells
16.34.12.Shared Size GroupsShared Size Groups
16.34.13.DoubleSplit WindowDoubleSplit Window
16.34.14.Use the Grid to create a dialog box that uses the WPF layout APIUse the Grid to create a dialog box that uses the WPF layout API
16.34.15.Is Grid ReadOnlyIs Grid ReadOnly
16.34.16.Dynamically add Button to a Grid and add Action listenerDynamically add Button to a Grid and add Action listener
16.34.17.Setting Grid row heights in codeSetting Grid row heights in code
16.34.18.Layout Controls with Grid in codeLayout Controls with Grid in code
16.34.19.Show Grid lines in codeShow Grid lines in code
16.34.20.Put Button onto a GridPut Button onto a Grid
16.34.21.Use the IsSharedSizeScope attached property of the Grid elementUse the IsSharedSizeScope attached property of the Grid element
16.34.22.Change the margins of an element that is within a Grid by XAML and programmatic codeChange the margins of an element that is within a Grid by XAML and programmatic code
16.34.23.Programmatically use the positioning methods of GridProgrammatically use the positioning methods of Grid
16.34.24.The default GroupStyle indents the items in a groupThe default GroupStyle indents the items in a group
16.34.25.A resizable layoutbased on GridA resizable layoutbased on Grid