Hi, I'm trying to bind to DataItemIndex inside CellValuePresenter's ControlTemplate that's inside XamDataGrid (complete project attached):
<ControlTemplate TargetType="igDP:CellValuePresenter"> <Button Content="{Binding DataItemIndex}" Click="Button_Click" /> </ControlTemplate>
Unfortunately, if I delete a row, none of subsequent rows update their button's content even though DataItemIndex value changed and is visible in Button_Click handler.
If I bind to "Index" then everything works correctly. Is this a bug ?
Hello,
Thank you for your post. I have been looking into and the sample you provided and I can say that this behavior is expected and occurs by design and the DataItemIndex doesn’t triggers the Binding due to performance optimizations of the XamDataGrid. The VisibleIndex Property works the same way, only the Index Property Triggers the Binding. If you have further questions regarding this feel free to ask.
Looking forward for your reply.
1. Would be great if such important piece of information was provided in documentation of these properties. Also consider marking them with [Bindable(false)].
2. How can I convert Index to DataItemIndex while called from PropertyChanged(Index) ? Can I assume DataItemIndex has correct value at this point ? To be more specific I'm thinking about simulating binding of DataItemIndex with multibinding to {Index, DataRecord} and using converter that returns value[1].DataItemIndex.