Sharker Khaleed Mahmud Silverlight Tips & Tricks

January 25, 2010

Tricks and Tips 18 : Using Line in silverlight

Filed under: Silverlight — Tags: , , , , — shamrat231 @ 9:14 AM

This is a demonstration of using line class.

MainPage.xaml.cs

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;

namespace Tips
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Line line = new Line();
            line.Stroke = new SolidColorBrush(Colors.Orange);
            line.StrokeThickness = 3.00;
            line.X1 = 10.00;
            line.X2 = 100.00;
            line.Y1 = 100.00;
            line.Y2 = 100.00;
            Line lR = new Line();
            lR.Stroke = new SolidColorBrush(Colors.Orange);
            lR.StrokeThickness = 3.00;
            lR.X1 = line.X2 – 10.00;
            lR.X2 = line.X2;
            lR.Y1 = line.Y2 + 10.00;
            lR.Y2 = line.Y2;
            Line lL = new Line();
            lL.Stroke = new SolidColorBrush(Colors.Orange);
            lL.StrokeThickness = 3.00;
            lL.X1 = line.X2 – 10.00;
            lL.X2 = line.X2;
            lL.Y1 = line.Y2 – 10.00;
            lL.Y2 = line.Y2;
            LayoutRoot.Children.Add(line);
            LayoutRoot.Children.Add(lR);
            LayoutRoot.Children.Add(lL);
        }
    }
}

Sharker Khaleed Mahmud
Software Developer

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.