title: UserControl Location in WPF
body: <p>I am new in WPF, I created a new UserControl MyUserControl. </p>
  
  <p>Now I am surprised: the UserContol does not have a location.</p>
  
  <p>How can I read (by code) myUserControl1.<code>Location</code> in the parent container?</p>
  
  <p>I explain: </p>
  
  <p>I have some Dots (UserControls) that the user can drag in a panel. Actually, I am not sure what kind of Panel this will be... Perhaps Grid.</p>
  
  <p>Now, these dots should be linked with a Line. </p>
  
  <p>Actually, I have a <code>Dot.Head</code> and <code>Dot.Queue</code> properties (also Dots). So, when a Head or Queue is added, I need to dinamically create a link (Line) between them [A]-----[B]. This for this Line I search the Start and End points to set.   </p>
  
  <p>Control XAML: </p>
  
  <pre><code>&lt;UserControl x:Class="LinePlan.Stop"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" d:DesignHeight="21" d:DesignWidth="80"&gt;
      &lt;Canvas&gt;
          &lt;Path Fill="LightBlue" Width="16" Height="16"&gt;
              &lt;Path.Data&gt;
                  &lt;EllipseGeometry x:Name="Dot" Center="8,8" 
                      RadiusX="4" RadiusY="4"/&gt;
              &lt;/Path.Data&gt;
          &lt;/Path&gt;
          &lt;TextBlock x:Name="StopText" Text="Eiffel Tower" Canvas.Left="16"/&gt;
      &lt;/Canvas&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>Code: </p>
  
  <pre><code>public partial class Stop : UserControl
  {
      private Stop head;
      private Stop tail;
      private LineGeometry headLine;
      private LineGeometry queueLine;
  
      public Stop()
      {
          InitializeComponent();
      }
  
      public Stop Head
      {
          get { return head; }
          set
          {
              if (head != value)
              {
                  head = value;
                  if (head == null) 
                  {
                      if (headLine != null)
                          headLine = null;
                  }
                  else
                  {
                      headLine = new LineGeometry();
                      headLine.StartPoint = head.DotPosition;
                      headLine.EndPoint = this.DotPosition;
  
                      // ?? Add this line to the parent
                  }
  
              }
          }
      }
  
      public Stop Tail
      {
          get { return tail; }
          set { tail = value; }
      }
  
      public Point DotPosition
      {
          get
          {
              double x = Canvas.GetLeft(this) + this.Dot.Center.X;
              double y = Canvas.GetTop(this) + this.Dot.Center.Y;
              return new Point(x, y);
          }
          set
          {
              Canvas.SetLeft(this, value.X - this.Dot.Center.X);
              Canvas.SetTop(this, value.Y - this.Dot.Center.Y);
          }
      }
  }
  </code></pre>