Set Top and left dimension based on its container
<Window x:Class="WpfApplication1.ShapesWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ShapesWindow" Height="160" Width="400">
<StackPanel Orientation="Horizontal">
<Line Stroke="Purple" X1="40" X2="0" Y1="0" Y2="120"/>
</StackPanel>
</Window>
Related examples in the same category