The following XAML code adds text to a Line UIElement. In this example the text is presented by a <TextBlock... />
. The text is centered at the Line, but this can easily be changed by the TextAlignment
property.
<Grid>
<TextBlock Text="{Binding RelationName}" TextAlignment="Center" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Line Stroke="Black" X1="{Binding From.CanvasCenterX}" Y1="{Binding From.CanvasCenterY}" X2="{Binding To.CanvasCenterX}" Y2="{Binding To.CanvasCenterY}" StrokeThickness="2" />
</Grid>
VerticalAlignment
and HorizontalAlignment
places the <TextBlock../>
in the <Grid../>