I built a custom DataGrid in WPF where I added filtering via popup. I initially managed all the interactions via code-behind, but recently moved to a pure MVVM approach. Everything is in a shared library and the DataGrid has its own internal viewmodel (not expose to clients).
This viewmodel DataGridViewModel has an ObservableCollection as property. Each DataGridColumnHeaderViewModel has the property IDataGridColumnHeaderFilterContent where different implementations are used for dates, string or more complex objects to filter.
Everything works well, because I temporarily "duplicated" the property IDataGridColumnHeaderFilterContent to DataGridViewModel where I currently bind. Basically, it corresponds to a shared popup amongst all columns. I can't filter 2 columns simultaneously (with the popup staying open).
For example inside the popup :
Ideally, I want the binding something like Content="{Binding HeadersColumns[name].HeaderFilterContent}". but also have the toggle button, etc. to be bound to the corresponding DataGridColumnHeaderViewModel from the ObservableCollection.
I've already been fighting with ChatGPT for more than 2 days without success. I believe the issue comes from the popup (or even the DataGridColumnHeader which is not part of the visual tree). I mostly tried to use a biding proxy, converters, changed the DataContext in the code-behind from what I remember but probably forgot most of my attempts because I've got so confused.
Does anyone have an idea how to cope with this situation?