I have a UserControl related to ViewModel. In UserControl it is attached to the list of elements (class objects). Therefore, when I want to bind various elements to properties in the RowDetails DataGrid template, I use:
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.SomeProperty}"
It works great. Now I want to split the RowDetails stuff into a UserControl, which I can use in other top-level UserControls with DataGrids on them. So, how do I find UserControl, which is the ancestor of UserControl, in which this binding statement is written?
I cannot specify the top-level name of the UserControl in the x: Type declaration, because it is different every time.
source share