private void ContentControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { //how to get the coordinates of the mouse click here on the image? if (Spiel.running == false) { return; } Spiel.erhoeheClicks(); Clicks.Text = Spiel.current.Clicks.ToString(); Point p = Spiel.point; Point b = e.GetPosition(TheImage); Point diagonalh = new Point(this.TheImage.Width, this.TheImage.Height); double diagonal = Point.Subtract(new Point(0, 0), diagonalh).Length; double distance = Point.Subtract(b, p).Length; double num = (ellipse.Width / 2) / diagonal; distance = distance / diagonal; if (distance <= num) { Ellipse final = new Ellipse(); final.Width = ellipse.Width; final.Height = ellipse.Height; final.StrokeThickness = ellipse.StrokeThickness; final.Fill = Brushes.Black; Cnv.Children.Add(final); Canvas.SetLeft(final, p.X); Canvas.SetTop(final, p.Y); Login.Visibility = Visibility.Visible; int index = 0; for (var i = 0; i < Members.Count; i++) { if (Members[i].Clicks > Spiel.current.Clicks) { break; } index += 1; } Spiel.current.Rank = index + 1; for (var i = 0; i < Members.Count; i++) { if (Members[i].Clicks == Spiel.current.Clicks) { Spiel.current.Rank = Members[i].Rank; equalRank = true; } } Members.Insert(index, Spiel.current); if (equalRank == false) { for (var i = index + 1; i < Members.Count; i++) { Members[i].Rank += 1; } } CollectionViewSource.GetDefaultView(this.Members).Refresh(); Spiel.setFinal(setRandom()); Cnv.Children.RemoveRange(4, Cnv.Children.Count - 3); Spiel.running = false; //MessageBox.Show("Hi"); } else { Color c = colour.GetColor(distance); SolidColorBrush mySolidColorBrush = new SolidColorBrush(); mySolidColorBrush.Color = c; Ellipse newEll = new Ellipse(); newEll.Width = ellipse.Width; newEll.Height = ellipse.Height; newEll.StrokeThickness = ellipse.StrokeThickness; newEll.Fill = mySolidColorBrush; Cnv.Children.Add(newEll); Canvas.SetLeft(newEll, e.GetPosition(TheImage).X); Canvas.SetTop(newEll, e.GetPosition(TheImage).Y); } }