public void MouseUp() { if (currentPath == null) { return; } if (pathSegmentCollection.Count > 2) { var col = new System.Windows.Media.Color(); col.A = 100; col.G = 255; currentPath.Stroke = new SolidColorBrush(col); currentPath.ContextMenu = new ContextMenu(); var path = currentPath; currentPath.ContextMenu.Items.Add(GraphScroller.CreateMenuItem("Remove polyline", () => RemovePath(path))); PathToShape(currentPath); } currentPath = null; }