シンプルなカスタム ユーザー コントロールがあります。
<Grid x:Name="LayoutRoot">
<StackPanel>
<TextBlock Text="{Binding DisplayText}"/>
<TextBlock Text="{Binding PersonName}"/>
</StackPanel>
</Grid>
MainPage.xaml で次のように使用します。
<local:WindowsPhoneControl1 x:Name="customControl" DisplayText="test">
</local:WindowsPhoneControl1>
MainPage.xaml.cs の場合:
PersonName = "George";
customControl.DataContext = this;
次に、Georgeが表示されますが、testは表示されません。これは理にかなっていますが、DisplayText プロパティにバインドする方法がわかりません。
もちろん、Georgeが表示されないため、以下は機能しません。
customControl.DataContext = customControl;
これは WP/silverlight 開発では機能するはずなので、AncestorType などは利用できない可能性があることに注意してください (必ずしも有用であるとは限りません)。