user3610920
user3610920

Reputation: 1652

How to use ink canvas using predifined x, y values?

I have some set of x,y values,I want to bind them to my xamal and while executing the application it needs to draw the stroke automatically without any input from the user. Is that possible with ink canvas or do i need to use any other control?

Upvotes: 0

Views: 61

Answers (1)

grek40
grek40

Reputation: 13458

You can add strokes in code, like I do in the loaded event:

<InkCanvas Loaded="InkCanvas_Loaded"/>

Code:

private void InkCanvas_Loaded(object sender, RoutedEventArgs e)
{
    var s = sender as InkCanvas;
    s.Strokes.Add(new System.Windows.Ink.Stroke(new StylusPointCollection(new Point[]
    {
        new Point(10, 10),
        new Point(100, 10),
        new Point(100, 100),
        new Point(10, 100),
        new Point(10, 10),
    })));
}

Upvotes: 1

Related Questions