private void AddFunc_Click(object sender, RoutedEventArgs e) { if (graph != null) { int index = graph.CustomFunctions.Count; string name = "Func" + index; FunctionGraph gp = new FunctionGraph(name); gp.AssignParentGraph(graph); graph.AddCustomFunction(gp); FunctionView cp = new FunctionView(gp); cp.OnRemove += Cp_OnRemove; Stack.Children.Add(cp); } }