A quick and dirty way is to use the lines and associate their coordinates with the width and height of some parent container. Something like that:
<Grid Name="parent"> <Line X1="0" Y1="0" X2="{Binding ElementName='parent', Path='ActualWidth'}" Y2="{Binding ElementName='parent', Path='ActualHeight'}" Stroke="Black" StrokeThickness="4" /> <Line X1="0" Y1="{Binding ElementName='parent', Path='ActualHeight'}" X2="{Binding ElementName='parent', Path='ActualWidth'}" Y2="0" Stroke="Black" StrokeThickness="4" /> </Grid>
Using a grid as a parent means that other children are added to the grid after the lines appear on top of the lines:
<Grid Name="parent"> <Line X1="0" Y1="0" X2="{Binding ElementName='parent', Path='ActualWidth'}" Y2="{Binding ElementName='parent', Path='ActualHeight'}" Stroke="Black" StrokeThickness="4" /> <Line X1="0" Y1="{Binding ElementName='parent', Path='ActualHeight'}" X2="{Binding ElementName='parent', Path='ActualWidth'}" Y2="0" Stroke="Black" StrokeThickness="4" /> <Label Background="Red" VerticalAlignment="Center" HorizontalAlignment="Center">My Label</Label> </Grid>
source share