I'm new to C# programming so maybe this is obvious but I couldn't find correct solution yet. I'd need help for coding the correct destructor that deletes the created panel dynamically. In this page there is an example code for adding new panel from the AddOn to chart windows top: https://ninjatrader.com/support/help...erence_wip.htm
protected override void OnWindowCreated(Window window)
{
// Obtain a reference to any chart that triggered OnWindowCreated
Chart Window = window as Chart;
// Instantiate a grid to hold a reference to the content of the chart window
Grid mainWindowGrid = Window.Content as Grid;
// Add existing row definition for existing row if it is not present
if (mainWindowGrid.RowDefinitions.Count == 0)
{
mainWindowGrid.RowDefinitions.Add(new RowDefinition());
}
// Instantiate a RowDefinition and set its height
RowDefinition row = new RowDefinition();
row.Height = new GridLength(PanelLength);
// Insert the new row into the chart's main window grid
mainWindowGrid.RowDefinitions.Insert(0, row);
//Move Existing Elements down one row, since our new content will take the top row
foreach (UIElement element in mainWindowGrid.Children)
{
element.SetValue(Grid.RowProperty, (int)element.GetValue(Grid.RowProperty) + 1);
}
//Create the Top Panel grid and add it to our newly defined row
Grid Panel = new Grid();
Panel.SetValue(Grid.RowProperty, 0);
mainWindowGrid.Children.Add(Panel);
//Create a sample text block and add it to the Top/Bottom Panel Grid.
TextBlock TextBlock = new TextBlock();
TextBlock.Text = PanelDirection.ToString() + " Panel (" + PanelLocation.ToString() + ") Sample Text Block";
TextBlock.Foreground = Brushes.Red;
TextBlock.SetValue(Grid.RowProperty, 0);
Panel.Children.Add(TextBlock);
}
cheers

Comment