2行目にバインドするには、次のGrid2つの方法があります。
最初に:RelativeSourceビニングによって:
<ComboBox DropDownOpened="ComboBox_DropDownOpened"
MaxDropDownHeight="{Binding Path=RowDefinitions[1].ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Grid}, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
2番目:ElementNameバインディングによる(この場合、グリッドで設定する必要がありますName="RootLayout"):
<ComboBox DropDownOpened="ComboBox_DropDownOpened"
MaxDropDownHeight="{Binding ElementName=RootLayout, Path=RowDefinitions[1].ActualHeight, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
DropDownOpenedイベントハンドラでは、クラスを使用しての値を更新する必要が ありますMaxDropDownHeight。BindingExpression
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
ComboBox cb = sender as ComboBox;
BindingExpression be = cb.GetBindingExpression(ComboBox.MaxDropDownHeightProperty);
be.UpdateTarget();
}