我在DataGrid中有一个字段,绑定到一个值(项目.金额),现在在该字段编辑器的样式中,我想将格式字段绑定到项目数量小数点.
但是,我似乎无法上树找到记录绑定到的同一项。
Format="{Binding Path=QuantityDecimalPoints, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DBO:Item}}}"
以及
Format="{Binding Path=QuantityDecimalPoints, RelativeSource={RelativeSource PreviousData}}"
您需要绑定到DataGridRow的DataContext上的属性(应该是同时包含Amount和QuantityDecimalPoints属性的项)。你可以这样做:
Format="{Binding DataContext.QuantityDecimalPoints, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"