2010-09-16 80 views
0

我在DataGrid中綁定了一個值(Item.Amount)的字段,現在在該字段編輯器的樣式中,我想將Format字段綁定到Item.QuantityDecimalPoints 。WPF DataGrid綁定編輯器設置爲另一個屬性

但我似乎無法上升到樹記錄綁定到相同的項目。

我曾嘗試以下:

Format="{Binding Path=QuantityDecimalPoints, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DBO:Item}}}" 

而且

Format="{Binding Path=QuantityDecimalPoints, RelativeSource={RelativeSource PreviousData}}" 

回答

1

您需要綁定到是在DataGridRow的DataContext的(這應該是包含兩個金額的項目屬性和QuantityDecimalPoints屬性)。你可以這樣做:

Format="{Binding DataContext.QuantityDecimalPoints, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" 
相關問題