Visual error
I’m facing an issue in my WPF application where I get the following exception:
Exception: The specified Visual is not an ancestor of this Visual
This happens specifically when I perform an extended selection on items that were recently added to a Observablecollection bound to my UI. The exception doesn’t occur with items that were already present before the selection, only with the newly added ones. It also occurs if I move the selection beyond the boundaries of the DataGrid.
Has anyone encountered this before, or does anyone have an idea where the problem might be coming from? Any guidance would be much appreciated!
https://paste.gg/p/anonymous/8ade3f8d4d4b4ec296572d9279e4d8351 Reply
Solution: Never rewrite the template of a DataGridRow, as you may miss a necessary control for extended selection, which I might not yet be aware of.