title: Custom Control DataBinding wpf
body: <p>Currently implementing a custom control I would like to bind some Value directly from my viewModel without using xaml. 
  I can do this:</p>
  
  <pre><code>&lt;customControls:MyControl MyValue="{Binding ElementName=MyElem, Path=Text}"&gt;
  &lt;Textbox Text="{Binding Mytext}" /&gt;
  </code></pre>
  
  <p>But not:</p>
  
  <pre><code>&lt;customControls:MyControl MyValue="{Binding MyText}"&gt;
  </code></pre>
  
  <p>The controls is defined in a template and inside the Control code my the MyProperty is defined as:</p>
  
  <pre><code>   public static readonly DependencyProperty MyValueProperty = DependencyProperty.Register("MyValue", typeof(double), typeof(CustomOEE), new FrameworkPropertyMetadata((Double)20,FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
     public double MyValue
     {
         get
         {
             return (double)GetValue(MyValueProperty);
         }
         set
         {
             SetValue(MyValueProperty, value);
  
         }
     }
  </code></pre>
  
  <p>Thanks a lot for your help</p>