private void BreakConnectionItem_Click(object sender, RoutedEventArgs e) { Console.WriteLine("Bye bye"); PanelConnection connection = (sender as MenuItem).Tag as PanelConnection; connection.Delete(); Connections.Remove(connection); Statement first = (connection.First as GStatement).GetBoundProperty() as Statement; Statement second = (connection.Second as GStatement).GetBoundProperty() as Statement; first.NextStatements.Remove(second); }