Добавить дочерний элемент в сетку,установить строку и столбец

Как я могу добавить объект Imageв Gridи установить его Row и Column ?

Сетка 3х3.

Основной файл:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="440" Width="400" ResizeMode="NoResize">
    <Window.Background>
        <ImageBrush ImageSource="C:\Users\GuyD\AppData\Local\Temporary Projects\WpfApplication1\AppResources\Background.png"></ImageBrush>
    </Window.Background>
    <Grid ShowGridLines="True" x:Name="myGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="42" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="32*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="31*" />
            <ColumnDefinition Width="26*" />
            <ColumnDefinition Width="32*" />
        </Grid.ColumnDefinitions>
    </Grid>
</Window>

Код файла:

public MainWindow()
{
     InitializeComponent();
     for (int i = 0; i < 3; i++)
     {
          for (int j = 0; j < 3; j++)
          {
               Image Box = new Image();
               this.myGrid.Children.Add(Box);
          }
     }
}
22
задан H.B. 28 July 2012 в 15:10
поделиться