Stretched GridSplitter


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

        <Grid Height="100" Width="400">
          <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="6" />
            <ColumnDefinition Width="2*" />
          </Grid.ColumnDefinitions>
        
          <Ellipse Grid.Column="0" Fill="Red" />
          <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
          <Ellipse Grid.Column="2" Fill="Blue" />
        </Grid>
</Page>

   
    
    
    
    
    
    
     


Panel.ZIndex


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid>
  <Button Width="75" Height="23" Margin="0,0" Panel.ZIndex="3" HorizontalAlignment="Left" VerticalAlignment="Top">
    One
  </Button>
  <Button Width="75" Height="23" Margin="15,15" Panel.ZIndex="2" HorizontalAlignment="Left" VerticalAlignment="Top">
    Two
  </Button>
  <Button Width="75" Height="23" Margin="30,30" Panel.ZIndex="1" HorizontalAlignment="Left" VerticalAlignment="Top">
    Three
  </Button>
</Grid>
</Page>

   
    
    
    
    
    
    
     


Without Panel.ZIndex


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid>
  <Button Width="75" Height="23" Margin="0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
    One
  </Button>
  <Button Width="75" Height="23" Margin="15,15" HorizontalAlignment="Left" VerticalAlignment="Top">
    Two
  </Button>
  <Button Width="75" Height="23" Margin="30,30" HorizontalAlignment="Left" VerticalAlignment="Top">
    Three
  </Button>
</Grid>
</Page>

   
    
    
    
    
    
    
     


Margin vs Padding and Grid


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  HorizontalAlignment="Center" VerticalAlignment="Center">
    <Grid ShowGridLines="True" Background="Cyan">
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="Auto" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <Button Grid.Column="0" Margin="20" Padding="0" >Click me!</Button>
      <Button Grid.Column="1" Margin="10" Padding="10">Click me!</Button>
      <Button Grid.Column="2" Margin="0"  Padding="20">Click me!</Button>
    </Grid>
</Page>

   
    
    
    
    
    
    
     


Grid in ScrollViewer


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  HorizontalAlignment="Center" VerticalAlignment="Center">
<ScrollViewer>
  <Grid>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*" />
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <Border Grid.Column="0" Grid.Row="0" Background="LightGray" BorderBrush="Gray" BorderThickness="1">
      <TextBlock>Key</TextBlock>
    </Border>
    <Border Grid.Column="1" Grid.Row="0" Background="LightGray" BorderBrush="Gray" BorderThickness="1">
        <TextBlock>Value</TextBlock>
    </Border>
    <Border Grid.Column="2" Grid.Row="0" Background="LightGray" BorderBrush="Gray" BorderThickness="1">
      <TextBlock>Value 2</TextBlock>
    </Border>
    <TextBlock Grid.Column="0" Grid.Row="1" Text="WPF" />
    <TextBlock Grid.Column="1" Grid.Row="1" Text="Inc." />
    <TextBlock Grid.Column="2" Grid.Row="1" Text="this" />
    <TextBlock Grid.Column="0" Grid.Row="2" Text="is" />
    <TextBlock Grid.Column="1" Grid.Row="2" Text="a" />
    <TextBlock Grid.Column="2" Grid.Row="2" Text="test" />
  </Grid>
</ScrollViewer>
</Page>

   
    
    
    
    
    
    
     


Multiple Items in a Grid Cell


   
       
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid Background="Beige">
  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>
  <Rectangle Grid.Column="1" Grid.Row="2" Grid.RowSpan="3" Margin="5,3" Fill="White" />
  <Rectangle Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="2" Grid.RowSpan="2" Margin="5,3" Fill="White" />
  <TextBlock Grid.Column="0" Grid.Row="0">Title:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="0">value</TextBlock>
  <Rectangle Grid.Row="1" Grid.ColumnSpan="2" Margin="5" Height="1" Fill="Black" />

  <TextBlock Grid.Column="0" Grid.Row="2">A:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="2">a</TextBlock>
  <TextBlock Grid.Column="0" Grid.Row="3">B:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="3">b</TextBlock>
  <TextBlock Grid.Column="0" Grid.Row="4">C:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="4">c</TextBlock>

  <Rectangle Grid.Row="5" Grid.ColumnSpan="2" Margin="5" Height="1" Fill="Black" />

  <TextBlock Grid.Column="0" Grid.Row="6">Q:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="6">q</TextBlock>
  <TextBlock Grid.Column="0" Grid.Row="7">W:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="7">w</TextBlock>

</Grid>
</Page>

   
    
    
    
    
    
    
     


Show Grid Lines


   
       

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  HorizontalAlignment="Center" VerticalAlignment="Stretch">

<Grid ShowGridLines="True">
  <Grid.Resources>
    <Style TargetType="TextBlock">
      <Setter Property="Margin" Value="5,3" />
    </Style>
  </Grid.Resources>

  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto" />
    <ColumnDefinition />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="2*" />
    <RowDefinition Height="1*" />
  </Grid.RowDefinitions>
  <TextBlock Grid.Column="0" Grid.Row="0">Key:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="0">Value</TextBlock>
  <TextBlock Grid.Column="0" Grid.Row="1">A:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="1">a</TextBlock>
  <TextBlock Grid.Column="0" Grid.Row="2">B:</TextBlock>
  <TextBlock Grid.Column="1" Grid.Row="2">b</TextBlock>

</Grid>



</Page>