問題はRelativeSource
は次の場合には機能しません。私はバインディングにブレークポイントを設定した場合、私はエラーを取得します。5.関連ソースとポップアップ
//From MainPage.xaml
<Grid x:Name="LayoutRoot" Background="White" Height="100" Width="200">
<Popup IsOpen="True">
<TextBlock Text="{Binding Path=DataContext, RelativeSource={RelativeSource AncestorType=Grid}}" />
</Popup>
</Grid>
//From MainPage.xaml.cs
public MainPage()
{
InitializeComponent();
DataContext = "ololo";
}
Silverlightを使用します。
System.Exception: BindingExpression_CannotFindAncestor.
私はElementName=LayoutRoot
の代わりRelativeSource
を使用する場合は、すべてがOKになります。
なぜ相対ソースバインディングが機能しないのですか?
それはポップアップコントロールにとっては明らかです。 ComboBoxItemTemplateで相対ソースを使用する方法はありますか? –