xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.Window1"
Title="Grid Methods Sample">
Column 0, Row 0
Column 1, Row 0
Column 2, Row 0
Column 0, Row 1
Column 1, Row 1
Column 2, Row 1
Column 0, Row 2
Column 1, Row 2
Column 2, Row 2
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1
{
public partial class Window1 : Window
{
private void setCol0(object sender, RoutedEventArgs e)
{
Grid.SetColumn(rect1, 0);
Console.WriteLine("Column " + Grid.GetColumn(rect1).ToString());
}
private void setCol1(object sender, RoutedEventArgs e)
{
Grid.SetColumn(rect1, 1);
Console.WriteLine("Column " + Grid.GetColumn(rect1).ToString());
}
private void setCol2(object sender, RoutedEventArgs e)
{
Grid.SetColumn(rect1, 2);
Console.WriteLine("Column " + Grid.GetColumn(rect1).ToString());
}
private void setRow0(object sender, RoutedEventArgs e)
{
Grid.SetRow(rect1, 0);
Console.WriteLine("Row " + Grid.GetRow(rect1).ToString());
}
private void setRow1(object sender, RoutedEventArgs e)
{
Grid.SetRow(rect1, 1);
Console.WriteLine("Row " + Grid.GetRow(rect1).ToString());
}
private void setRow2(object sender, RoutedEventArgs e)
{
Grid.SetRow(rect1, 2);
Console.WriteLine("Row " + Grid.GetRow(rect1).ToString());
}
private void setColspan(object sender, RoutedEventArgs e)
{
Grid.SetColumnSpan(rect1, 3);
Console.WriteLine("ColumnSpan " + Grid.GetColumnSpan(rect1).ToString());
}
private void setRowspan(object sender, RoutedEventArgs e)
{
Grid.SetRowSpan(rect1, 3);
Console.WriteLine("RowSpan " + Grid.GetRowSpan(rect1).ToString());
}
private void clearAll(object sender, RoutedEventArgs e)
{
Grid.SetColumn(rect1, 0);
Grid.SetRow(rect1, 0);
Grid.SetColumnSpan(rect1, 1);
Grid.SetRowSpan(rect1, 1);
}
}
}