Define a GridSplitter and ShowsPreview Changed

image_pdfimage_print


   
  

<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
    <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>
      <StackPanel Margin="0,5,0,0">
        <TextBlock>ShowsPreview</TextBlock>
        <RadioButton Name="ShowsPreviewFalse" Checked="ShowsPreviewChanged" IsChecked="true" GroupName="ShowsPreviewProperty">
      false (default)
        </RadioButton>
        <RadioButton Name="ShowsPreviewTrue" Checked="ShowsPreviewChanged" GroupName="ShowsPreviewProperty">
         true
        </RadioButton>
      </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }

        private void ShowsPreviewChanged(object sender, RoutedEventArgs e)
        {
          if ((Boolean)ShowsPreviewFalse.IsChecked)
            myGridSplitter.ShowsPreview = false;
          else if ((Boolean)ShowsPreviewTrue.IsChecked)
            myGridSplitter.ShowsPreview = true;
        }
  
  }
}

   
    
     


GridSplitter and ResizeBehaviorChanged

image_pdfimage_print


   
  

<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
    <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>
    <StackPanel Margin="0,5,0,0">
      <TextBlock>GridResizeBehavior</TextBlock>
      <RadioButton Name="BehaviorBasedOnAlignment" Checked="ResizeBehaviorChanged" IsChecked="true" GroupName="GridResizeBehaviorProperty">
       BasedOnAlignment (default)
      </RadioButton>
      <RadioButton Name="BehaviorCurrentAndNext" Checked="ResizeBehaviorChanged" GroupName="GridResizeBehaviorProperty">
       CurrentAndNext
      </RadioButton>
      <RadioButton Name="BehaviorPreviousAndCurrent" Checked="ResizeBehaviorChanged" GroupName="GridResizeBehaviorProperty">
       PreviousAndCurrent
      </RadioButton>
      <RadioButton Name="BehaviorPreviousAndNext" Checked="ResizeBehaviorChanged" GroupName="GridResizeBehaviorProperty">
       PreviousAndNext
      </RadioButton>
    </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }

        private void ResizeBehaviorChanged(object sender, RoutedEventArgs e)
        {
          if ((Boolean)BehaviorBasedOnAlignment.IsChecked)
            myGridSplitter.ResizeBehavior = GridResizeBehavior.BasedOnAlignment;
          else if ((Boolean)BehaviorCurrentAndNext.IsChecked)
            myGridSplitter.ResizeBehavior = GridResizeBehavior.CurrentAndNext;
          else if ((Boolean)BehaviorPreviousAndCurrent.IsChecked)
            myGridSplitter.ResizeBehavior = GridResizeBehavior.PreviousAndCurrent;
          else if ((Boolean)BehaviorPreviousAndNext.IsChecked)
            myGridSplitter.ResizeBehavior = GridResizeBehavior.PreviousAndNext;
        }
  
  }
}

   
    
     


Define a GridSplitter and Resize Direction Changed

image_pdfimage_print


   
  
<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
    <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>
      <StackPanel Margin="0,5,0,0">
        <TextBlock>ResizeDirection</TextBlock>
        <RadioButton Name="ResizeDirectionAuto" Checked="ResizeDirectionChanged" IsChecked="true" GroupName="ResizeDirectionProperty">
        Auto (default)
        </RadioButton>
        <RadioButton Name="ResizeDirectionCols" Checked="ResizeDirectionChanged" GroupName="ResizeDirectionProperty">
        Columns
        </RadioButton>
        <RadioButton Name="ResizeDirectionRows" Checked="ResizeDirectionChanged" GroupName="ResizeDirectionProperty">
        Rows
        </RadioButton>
      </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }

        private void ResizeDirectionChanged(object sender, RoutedEventArgs e)
        {
          if ((Boolean)ResizeDirectionAuto.IsChecked)
            myGridSplitter.ResizeDirection = GridResizeDirection.Auto;
          else if ((Boolean)ResizeDirectionCols.IsChecked)
            myGridSplitter.ResizeDirection = GridResizeDirection.Columns;
          else if ((Boolean)ResizeDirectionRows.IsChecked)
            myGridSplitter.ResizeDirection = GridResizeDirection.Rows;
        }
  
  }
}

   
    
     


Define a GridSplitter and Keyboard Increment

image_pdfimage_print


   
  

<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
    <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>

      <StackPanel Margin="0,5,0,0">
        <TextBlock>KeyboardIncrement</TextBlock>
        <RadioButton Name="KeyboardIncrementAuto" Checked="KeyboardIncrementChanged" IsChecked="true" GroupName="KeyboardIncrementProperty">
        1 (default)
        </RadioButton>
        <RadioButton Name="KeyboardIncrementCols" Checked="KeyboardIncrementChanged" GroupName="KeyboardIncrementProperty">
        20
        </RadioButton>
        <RadioButton Name="KeyboardIncrementRows" Checked="KeyboardIncrementChanged" GroupName="KeyboardIncrementProperty">
        50
        </RadioButton>
        <RadioButton Name="KeyboardIncrementBoth" Checked="KeyboardIncrementChanged" GroupName="KeyboardIncrementProperty">
        100
        </RadioButton>
      </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }

        private void KeyboardIncrementChanged(object sender, RoutedEventArgs e)
        {
          if ((Boolean)KeyboardIncrementAuto.IsChecked)
            myGridSplitter.KeyboardIncrement = 1;
          else if ((Boolean)KeyboardIncrementCols.IsChecked)
            myGridSplitter.KeyboardIncrement = 20;
          else if ((Boolean)KeyboardIncrementRows.IsChecked)
            myGridSplitter.KeyboardIncrement = 50;
          else if ((Boolean)KeyboardIncrementBoth.IsChecked)
            myGridSplitter.KeyboardIncrement = 100;
        }
  
  }
}

   
    
     


GridSplitter and DragIncrement Changed

image_pdfimage_print


   
  
<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
    <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>

    <StackPanel Margin="0,5,0,0">
        <TextBlock>DragIncrement</TextBlock>
        <RadioButton Name="DragIncrementAuto" Checked="DragIncrementChanged" IsChecked="true" GroupName="DragIncrementProperty">
         1 (default)
        </RadioButton>
        <RadioButton Name="DragIncrementCols" Checked="DragIncrementChanged" GroupName="DragIncrementProperty">
         20
        </RadioButton>
        <RadioButton Name="DragIncrementRows" Checked="DragIncrementChanged" GroupName="DragIncrementProperty">
          50
        </RadioButton>
    </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }
        private void DragIncrementChanged(object sender, RoutedEventArgs e)
        {
          if ((Boolean)DragIncrementAuto.IsChecked)
            myGridSplitter.DragIncrement = 1;
          else if ((Boolean)DragIncrementCols.IsChecked)
            myGridSplitter.DragIncrement = 20;
          else if ((Boolean)DragIncrementRows.IsChecked)
            myGridSplitter.DragIncrement = 50;
        }
  
  }
}

   
    
     


Define a GridSplitter and Vertical Alignment Changed

image_pdfimage_print


   
  

<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
    <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>

    <StackPanel Margin="0,5,0,0">
      <TextBlock>VerticalAlignment</TextBlock>
      <RadioButton Name="VerticalAlignmentTop" Checked="VerticalAlignmentChanged" GroupName="VerticalAlignmentProperty">
        Top
      </RadioButton>
      <RadioButton Name="VerticalAlignmentBottom" Checked="VerticalAlignmentChanged" GroupName="VerticalAlignmentProperty">
        Bottom
      </RadioButton>
      <RadioButton Name="VerticalAlignmentCenter" Checked="VerticalAlignmentChanged" GroupName="VerticalAlignmentProperty">
        Center
      </RadioButton>
      <RadioButton Name="VerticalAlignmentStretch" Checked="VerticalAlignmentChanged" IsChecked="true" GroupName="VerticalAlignmentProperty">
        Stretch (default)
      </RadioButton>
    </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }
        private void VerticalAlignmentChanged(object sender, RoutedEventArgs e)
        {
          if ((Boolean)VerticalAlignmentTop.IsChecked)
            myGridSplitter.VerticalAlignment = VerticalAlignment.Top;
          else if ((Boolean)VerticalAlignmentBottom.IsChecked)
            myGridSplitter.VerticalAlignment = VerticalAlignment.Bottom;
          else if ((Boolean)VerticalAlignmentCenter.IsChecked)
            myGridSplitter.VerticalAlignment = VerticalAlignment.Center;
          else if ((Boolean)(Boolean)VerticalAlignmentStretch.IsChecked)
            myGridSplitter.VerticalAlignment = VerticalAlignment.Stretch;
        }
  }
}

   
    
     


Define a GridSplitter and Horizontal Alignment Changed

image_pdfimage_print


   
  

<Window x:Class="GridSplitter_Example.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="GridSplitter Example">
<Grid>
  <Grid.ColumnDefinitions>
    <ColumnDefinition Name="Col0" />
    <ColumnDefinition Name="Col1" />
    <ColumnDefinition Name="Col2" />
    <ColumnDefinition Name="Col3" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Name="Row0" />
    <RowDefinition Name="Row1" />
    <RowDefinition Name="Row2" />
  </Grid.RowDefinitions>

  <StackPanel Grid.Row="0" Grid.Column="0" Background="Orange">
    <TextBlock>Row 0 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="0" Background="Blue">
    <TextBlock>Row 1 Col 0</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="0" Background="Green">
    <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="1" Background="Purple">
    <TextBlock>Row 0 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="1" Background="Red">
    <TextBlock>Row 1 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="1" Background="Salmon">
   <TextBlock>Row 2 Col 1</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="0" Grid.Column="2" Background="MediumVioletRed">
    <TextBlock>Row 0 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="1" Grid.Column="2" Background="SteelBlue">
    <TextBlock>Row 1 Col 2</TextBlock>
  </StackPanel>
  <StackPanel Grid.Row="2" Grid.Column="2" Background="Olive">
    <TextBlock>Row 2 Col 2</TextBlock>
  </StackPanel>
   
  <GridSplitter Name="myGridSplitter" Grid.Column="1" Grid.Row="1" Width="5"/>
  <StackPanel Grid.Column="3" Grid.RowSpan="3" Background="Brown">
  <TextBlock FontSize="14" Foreground="Yellow">Property Settings</TextBlock>
    <StackPanel>
      <TextBlock >HorizontalAlignment</TextBlock>
      <RadioButton Name="HorizontalAlignmentLeft" Checked="HorizontalAlignmentChanged" GroupName="HorizontalAlignmentProperty">
        Left
      </RadioButton>
      <RadioButton Name="HorizontalAlignmentRight" Checked="HorizontalAlignmentChanged" IsChecked="true" GroupName="HorizontalAlignmentProperty">
        Right (default)
      </RadioButton>
      <RadioButton Name="HorizontalAlignmentCenter" Checked="HorizontalAlignmentChanged" GroupName="HorizontalAlignmentProperty">
        Center
      </RadioButton>
      <RadioButton Name="HorizontalAlignmentStretch" Checked="HorizontalAlignmentChanged" GroupName="HorizontalAlignmentProperty">
        Stretch
      </RadioButton>
    </StackPanel>
  </StackPanel>
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GridSplitter_Example
{
  public partial class Window1 : Window
  {
      public Window1()
      {
        InitializeComponent();
      }
      private void HorizontalAlignmentChanged(object sender, RoutedEventArgs e)
      {
          if ((Boolean)HorizontalAlignmentLeft.IsChecked)
            myGridSplitter.HorizontalAlignment = HorizontalAlignment.Left;
          else if ((Boolean)HorizontalAlignmentRight.IsChecked)
            myGridSplitter.HorizontalAlignment = HorizontalAlignment.Right;
          else if ((Boolean)HorizontalAlignmentCenter.IsChecked)
            myGridSplitter.HorizontalAlignment = HorizontalAlignment.Center;
          else if ((Boolean)HorizontalAlignmentStretch.IsChecked)
            myGridSplitter.HorizontalAlignment = HorizontalAlignment.Stretch;
      }
  }
}