locked
Creating Line segment From Code Behind in windows store apps RRS feed

  • Question

  • I want to Draw a line segment in windows store apps from code behind i.e from .cs file not from design i.e. not from XAML.

    I have a line drawn from desgin Part

    <Line Grid.Row="0"
                          Margin="25,0,0,0"                      
                          Stroke="#515459"
                          StrokeThickness="2"
                          X2="1000" />

    I want very similar kind of line to be drawn from code behind. so please provide some suggestion .

    Thanks in advance.

    Tuesday, May 20, 2014 9:49 AM

Answers

  • Finally I got the answer.

    var line = new Line();
                line.X1 = 0;
                line.X2 = 1000;
                line.Stroke = new SolidColorBrush(Colors.Red);
                line.StrokeThickness = 2;
                grdLine.Children.Add(line);

    • Marked as answer by Anne Jing Wednesday, May 21, 2014 1:02 AM
    Tuesday, May 20, 2014 10:22 AM