Draws a diagonal line from (10,10) to (40,50)
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Fun with Graphics!" Height="345" Width="452">
<Canvas>
<Line Name="myLine" MouseDown ="myLine_Clicked" Cursor ="Hand"
X1="10" Y1="10" X2="40" Y2="90"
Stroke="Black" StrokeThickness="15"
StrokeEndLineCap ="Round" StrokeStartLineCap ="Triangle"/>
</Canvas>
<x:Code>
public void myLine_Clicked(Object sender, MouseButtonEventArgs e)
{
MessageBox.Show("You clicked the line!");
}
</x:Code>
</Window>
Related examples in the same category