Drawing things on a Canvas

前端 未结 2 813
半阙折子戏
半阙折子戏 2020-12-19 00:01

How would I draw something on a Canvas in C# for Windows Phone?

Okay, let me be a little more clear.

Say the user taps his finger down at 386,43 on the canvas. (the ca

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-19 00:20

    There are various ways of doing this. Depending on the nature of the red dot, you could make it a UserControl. For a basic circle, you can simply handle your canvas' ManipulationStarted event.

    private void myCanvas_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
    {
    
                Ellipse el = new Ellipse();
                el.Width = 10;
                el.Height = 10;
                el.Fill = new SolidColorBrush(Colors.Red);
                Canvas.SetLeft(el, e.ManipulationOrigin.X);
                Canvas.SetTop(el, e.ManipulationOrigin.Y);
                myCanvas.Children.Add(el);
    }
    

提交回复
热议问题