Hi
I have recently dynamically created a grid but am unsure of how to access it to change its properties (i.e. its background color). this is on WPF so control doesn't seem to work. I was just wondering if I perhaps did something wrong or am not understanding the fundamentals of creating dynamic objects. I'm fairly new to WPF so apologies if this is something very basic.
Here is the code I am using to create the grid;
For a = 0 To noOfPanels
For i = 0 To (panelno - 1)
Dim Snake_block As New Grid
Snake_block.Name = "snakeBlock" & i & "_" & a
Snake_block.Height = Panel_Height
Snake_block.Width = Panel_Height
Snake_block.Background = New SolidColorBrush(Color.FromRgb(20, 224, 13))
Snake_block.HorizontalAlignment = Windows.HorizontalAlignment.Left
Snake_block.VerticalAlignment = VerticalAlignment.Top
Dim margin_thickness As New Thickness
margin_thickness.Left = (panelSpaceSize * (i + 1)) + (Panel_Height * i)
margin_thickness.Top = (top_space * (a + 1)) + (Panel_Height * a)
If i = 19 Then
margin_thickness.Right = panelSpaceSize
End If
margin_thickness.Bottom = 0
Snake_block.Margin = margin_thickness
Grid.SetColumn(Snake_block, 1)
myGrid.Children.Add(Snake_block)
Next
Next
Thank you.