I am using below code in my indicator and printing for debugging:
protected void CreateWPFControls()
{
chartWindow = System.Windows.Window.GetWindow(ChartControl.Paren t) as Chart;
chartGrid = chartWindow.MainTabControl.Parent as System.Windows.Controls.Grid;
buttonGrid = new System.Windows.Controls.Grid();
int tabShowing = chartGrid.Children.Count - 3;
Print(" 1 : " + tabShowing);
if (tabShowing < 1)
{
buttonGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition() { Height = new GridLength(210) });
Print("start count : " + buttonGrid.Children.Count);
Print(" 1.1 : " + tabShowing);
}
else
{
Print(" 2 : " + tabShowing);
int count = tabShowing;
Print("Before count : " + buttonGrid.Children.Count);
buttonGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition() { Height = new GridLength(50 * count) });
Print("after count : " + buttonGrid.Children.Count);
}
TextBlock label = new TextBlock()
{
Width = 200,
Height = 100
};
Print(" 3 : " + tabShowing);
for (int i = tabShowing; i < tabShowing + 1; i++)
{
Grid.SetRow(label, i);
buttonGrid.Children.Add(label);
Print(i+"============");
}
}
So from my debuggin through printing, I found though
if (tabShowing < 1)
is true, still
buttonGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition() { Height = new GridLength(210) });
is not adding the row and again when it goes to else following other actions, it does not execute
buttonGrid.RowDefinitions.Add(new System.Windows.Controls.RowDefinition() { Height = new GridLength(50 * count) });
Any reason, why it does not execute, as my printing of buttonGrid.Children.Count shows 0
Can anyone advise please?
Comment