Figuratively speaking, there is an image of a tank that can move in any direction. But when the tank leaves the playing field, the image of the tank disappears, and it is necessary that the tank stops near the edge of the field (the image should not disappear).
Here is the image transfer code:
private void KeyDowdDo(object sender, KeyEventArgs e) { if (e.Key == Key.Right) image.Margin = new Thickness(image.Margin.Left + 3, image.Margin.Top, 0, 0); if (e.Key == Key.Left) image.Margin = new Thickness(image.Margin.Left - 3, image.Margin.Top, 0, 0); if (e.Key == Key.Up) image.Margin = new Thickness(image.Margin.Left, image.Margin.Top - 3, 0, 0); if (e.Key == Key.Down) image.Margin = new Thickness(image.Margin.Left, image.Margin.Top + 3, 0, 0); } help me please!!!
image.Margin = new Thickness(image.Margin.Left, image.Margin.Top, 0, 0);- Komdosh