I am trying to make a grid of at least 3 rows that is aligned to the Bottom Left within the graph and I have the following example code, the code does not give me any errors when compiling the strategy but the grid or the texts are not seen in the graph, I do not know where the problem is, or if this is the best way to do it. Can you help me see where the error is to know why the grid is not visible? The code is the following:
// Crear un Grid para organizar los botones en filas y columnas
var gridPatrones = new System.Windows.Controls.Grid
{
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Bottom,
Margin = new Thickness(0, 0, 10, 0) // Margen para separar del borde derecho
};
// Definir las filas del Grid
gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Primera fila
gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Segunda fila
gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Tercera fila
gridPatrones.RowDefinitions.Add(new System.Windows.Controls.RowDefinition()); // Cuarta fila
// Definir las columnas del Grid (4 columnas para la primera fila, 3 para la segunda, tercera y cuarta)
gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 0
gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 1
gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 2
gridPatrones.ColumnDefinitions.Add(new System.Windows.Controls.ColumnDefinition()); // Columna 3 (nueva columna)
// Crear el TextBlock para "Gustaff 1" en la primera fila
var textBlockGustavito1 = new System.Windows.Controls.TextBlock
{
Text = "Gustff 1",
Foreground = System.Windows.Media.Brushes.White,
Background = System.Windows.Media.Brushes.Green,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Padding = new Thickness(10)
};
// Añadir el TextBlock a la primera fila (fila 0) y columna 0
System.Windows.Controls.Grid.SetRow(textBlockGusta vito1, 0);
System.Windows.Controls.Grid.SetColumn(textBlockGu stavito1, 0);
gridPatrones.Children.Add(textBlockGustavito1);
// Crear el TextBlock para "Gusti 2" en la segunda fila
var textBlockGusti2 = new System.Windows.Controls.TextBlock
{
Text = "Gusti 2",
Foreground = System.Windows.Media.Brushes.White,
Background = System.Windows.Media.Brushes.Red,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Padding = new Thickness(10)
};
// Añadir el TextBlock a la segunda fila (fila 1) y columna 0
System.Windows.Controls.Grid.SetRow(textBlockGusti 2, 1);
System.Windows.Controls.Grid.SetColumn(textBlockGu sti2, 0);
gridPatrones.Children.Add(textBlockGusti2);
Thank you very much !!!

Comment