private void initArray()
 {
     for (int i = 0; i < 10; i++)
     {
         for (int j = 0; j < 10; j++)
         {
             cells[i, j] = new Cell();
             Grid.SetColumn(cells[i, j], i);
             Grid.SetRow(cells[i, j], j);
             mainGrid.Children.Add(cells[i, j]);
             cells[i, j].X = i;
             cells[i, j].Y = j;
         }
     }
 }
        private void boardChanged(object sender, PropertyChangedEventArgs e)
        {
            int count = 0;
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    UserControl c = new Cell();

                    switch (model.Board.Model.ElementAt(count).Value)
                    {
                        case BoardConstants.water:
                            c = cells[i, j];
                            c.MouseEnter += new MouseEventHandler(enter);
                            Grid.SetRow(c, j);
                            Grid.SetColumn(c, i);
                            break;
                        case BoardConstants.miss:
                            c = new Miss();
                            Grid.SetRow(c, j);
                            Grid.SetColumn(c, i);
                            break;
                        case BoardConstants.hit:
                            cells[i, j].rectangle.Fill = Brushes.LightBlue;
                            c = new Hit();
                            Grid.SetRow(c, j);
                            Grid.SetColumn(c, i);
                            break;
                        case BoardConstants.ship:
                            c = cells[i, j];
                            Grid.SetRow(c, j);
                            Grid.SetColumn(c, i);
                            break;
                        default:
                            break;
                    }
                    if (VisualTreeHelper.GetParent(c) == null)
                    {
                        mainGrid.Children.Add(c);
                    }
                    else
                    {
                        ((Grid)VisualTreeHelper.GetParent(c)).Children.Remove(c);
                        mainGrid.Children.Add(c);
                    }
                    count++;
                }
            }
        }