I am pretty new to WPF and am building an Charting application using WPF. I am adding new rows dynamically and it works perfectly. I am seeing a problem when removing rows. This is my code for adding rows
RowDefinition newRow = new RowDefinition();
newRow.Name = "ADX";
newRow.Height = new GridLength(1, GridUnitType.Star);
this.chartForm.sciChartControl.ContentGrid.RowDefinitions.Add(newRow);
Grid.SetRow(scs, this.chartForm.sciChartControl.ContentGrid.RowDefinitions.Count - 1);
this.techIndicatorToRowDefinitionMap["ADX"] = newRow;
and the code to remove the Row is
this.chartForm.sciChartControl.ContentGrid.RowDefinitions.Remove(this.techIndicatorToRowDefinitionMap["ADX"]);
When I remove the rows , it seems like random rows are removed. Can you tell me if there is an easier way to keep track of rows and delete them or if there is a bug in this code .
Thanks.