public void RemoveNode(INode node) { if (node is BaseOutputNode) { var sp = spOutputNodes.Children.OfType <StackPanel>().Where(x => x.Name == "nodeContainer" && x.Tag == node).FirstOrDefault(); spOutputNodes.RemoveChild(sp); OutputNodes.RemoveAll(x => x.Node == node); } else if (node is InputNode) { var sp = spInputNodes.Children.OfType <StackPanel>().Where(x => x.Name == "nodeContainer" && x.Tag == node).FirstOrDefault(); spInputNodes.RemoveChild(sp); InputNodes.RemoveAll(x => x.Node == node); } }