Currently implementing a custom control I would like to bind some Value directly from my viewModel without using xaml. I can do this:
<customControls:MyControl MyValue="{Binding ElementName=MyElem, Path=Text}">
<Textbox Text="{Binding Mytext}" />
But not:
<customControls:MyControl MyValue="{Binding MyText}">
The controls is defined in a template and inside the Control code my the MyProperty is defined as:
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);
}
}
Thanks a lot for your help