WindowsPhoneControl1.xaml.cs:
public partial class WindowsPhoneControl1
{
public static readonly DependencyProperty MyDpProperty =
DependencyProperty.Register("MyDp",
typeof (Color),
typeof (WindowsPhoneControl1),
new PropertyMetadata(default(Color)));
public Color MyDp
{
get { return (Color) this.GetValue(MyDpProperty); }
set { this.SetValue(MyDpProperty, value); }
}
...
}
WindowsPhoneControl1.xaml:
<UserControl x:Class="MyProj.WindowsPhoneControl1" x:Name="Uc" ...>
<Rectangle Width="200" Height="200" Fill="{Binding MyDp, ElementName=Uc}" />
<!--<Rectangle Width="200" Height="200" Fill="Red" /> Works fine-->
</UserControl>
MainPage.xaml:
<Grid x:Name="LayoutRoot">
<myProj:WindowsPhoneControl1 MyDp="SandyBrown" />
</Grid>
So why {Binding MyDp, ElementName=Uc}
doesn't work and what to do in this case?