title: WPF Position TextBlock/Label on the Line center
body: <p>Im trying to represent weighted graph with MVVM inside canvas
  so im representing graphs vertices and edges as observable collections and putting them into canvas ItemsControl. But I cant find any reasonable way to position text that represents weight on the center of line(graphs edge) </p>
  
  <p>my canvas xaml:</p>
  
  <pre><code>&lt;Canvas Background="Linen" ClipToBounds="True"
              Grid.Row="0" Grid.Column="0"&gt;
          &lt;ItemsControl ItemsSource="{Binding EdgeItems}"&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;Canvas/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Line Stroke="Black" StrokeThickness="4" 
                            X1="{Binding V1.X}" Y1="{Binding V1.Y}"
                            X2="{Binding V2.X}" Y2="{Binding V2.Y}"/&gt;                                                        
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
      &lt;/Canvas&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mx0ec.png" rel="nofollow">What i want to get</a></p>