views:

15

answers:

1

I have a field in a DataGrid, bound to a value (Item.Amount), now inside the style for that field editor, i would like to bind the Format field to Item.QuantityDecimalPoints.

But I cannot seem to be able to go up the tree to the same Item that the record is bound to.

I have tried the following:

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

And

Format="{Binding Path=QuantityDecimalPoints, RelativeSource={RelativeSource PreviousData}}"
+1  A: 

You need to bind to a property that is on the DataContext of the DataGridRow (which should be the item that contains both Amount, and QuantityDecimalPoints properties). You can do that like so:

Format="{Binding DataContext.QuantityDecimalPoints, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}"
Abe Heidebrecht