I have a WPF Window with 2 DataGrids, each DataGrids has 6 DataGridTextColumn columns.
Only thing I like is once user OR system resize any column width on DataGrid #1, my app should set same column widths on DataGrid #2.
First I thought I bind each column "Width" property and that's all, but according to these:
How to bind datagrid columns width in WPF (MVVM)
I was wrong.
I tried that Rachel mentioned "Alternatively, you can define your own DataGridCellTemplate with a control that has it's Width bound to whatever the property is on your DataItem"
but still no luck, column widths not updating at resizing.
Also, I tried with this: http://dotnetgenetics.blogspot.hu/2016/04/wpf-datagridcell-resize-event.html
At least I can catch resize event, but no idea how I can figure out that which DataGrid and which column sent this event to resize another DataGrid.
I prefer a XAML-only solution if any.
Could you help me please?
It looks I found one solution: WPF DataGrid Sync Column Widths
So my working solution is:
I handle LayoutUpdate event on both DataGrid, and I set new column widths like mentioned above by Ahmed Yasin Koçulu, but before I set new widths on DataGrid one, I unsubscribe LayouUpdate event on DataGrid two. When I finished setting new withd, I subcribe LayoutUpdate event again.
I'd still prefer a XAML-only solution if any