I try to do something like when I touch somewhere on the screen - that position show up a circle
But the problem is - everywhere I touch the screen, the circle always appears in the middle of my grid:
public void Draw_Circle(int x, int y)
{
SolidColorBrush scb_O = new SolidColorBrush(Colors.Red);
Ellipse elip = new Ellipse();
elip.Stroke = scb_O;
elip.StrokeThickness = 2;
elip.Height = dd;
elip.Width = dd;
Canvas.SetLeft(elip, (double)x);
Canvas.SetTop(elip, (double)y);
//elip.SetValue(Canvas.TopProperty, (double)x);
//elip.SetValue(Canvas.LeftProperty, (double)y);
try
{
ContentPanel.Children.Add(elip);
}
catch (Exception ex2)
{
MessageBox.Show("Error: " + ex2);
}
}
And the touch position:
protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
Point p1 = e.GetPosition(null);
int x = (int)p1.X;
int y = (int)p1.Y;
//MessageBox.Show(x + " , " + y + "\n" + p1.X + " , " + p1.Y);
Draw_Circle(x, y);
}