Dock DataGrid's column to the right
-
I have this DataGrid with three columns:
I would like 'Col3' to always be at the right side of the DataGris regardless how wide the DataGrid is. Since 'Col1' and 'Col3' has fixed widths, 'Col2' is free to dynamically change width. Is this possible to "Dock" 'Col3' to the right side of the DataGrid? I'm looking for a solution simular to a DockPanel:
-
I have this DataGrid with three columns:
I would like 'Col3' to always be at the right side of the DataGris regardless how wide the DataGrid is. Since 'Col1' and 'Col3' has fixed widths, 'Col2' is free to dynamically change width. Is this possible to "Dock" 'Col3' to the right side of the DataGrid? I'm looking for a solution simular to a DockPanel:
You mean "visible"? If you define it "on the right", it stays there. If the preceding columns are "too wide", you have to add scroll bars.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food
-
I have this DataGrid with three columns:
I would like 'Col3' to always be at the right side of the DataGris regardless how wide the DataGrid is. Since 'Col1' and 'Col3' has fixed widths, 'Col2' is free to dynamically change width. Is this possible to "Dock" 'Col3' to the right side of the DataGrid? I'm looking for a solution simular to a DockPanel:
You can "freeze" one of more columns, but only on the left-hand side: DataGrid.FrozenColumnCount Property (System.Windows.Controls) | Microsoft Docs[^] You might be able to make it appear on the right-hand side with a custom template, but it would probably require a lot of work. If you just want column 2 to fill the remaining space, set its width to
*
:<DataGridTextColumn Header="Col2" Width="*" />
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You can "freeze" one of more columns, but only on the left-hand side: DataGrid.FrozenColumnCount Property (System.Windows.Controls) | Microsoft Docs[^] You might be able to make it appear on the right-hand side with a custom template, but it would probably require a lot of work. If you just want column 2 to fill the remaining space, set its width to
*
:<DataGridTextColumn Header="Col2" Width="*" />
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer