xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.Window1"
Title="ColumnDefinitions Sample">
Grid Column and Row Collections
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace WpfApplication1
{
public partial class Window1 : Window
{
RowDefinition rowDef1;
ColumnDefinition colDef1;
private void containsRow(object sender, RoutedEventArgs e)
{
rowDef1 = new RowDefinition();
grid1.RowDefinitions.Insert(grid1.RowDefinitions.Count, rowDef1);
Console.WriteLine(grid1.RowDefinitions.IndexOf(rowDef1).ToString());
if (grid1.RowDefinitions.Contains(rowDef1))
{
Console.WriteLine("Grid Contains RowDefinition rowDef1");
}
else
{
Console.WriteLine("Grid Does Not Contain RowDefinition rowDef1");
}
}
}
}