Having some issues with column widths. I want to statitcally set the width of all my columns except one and that one I want to expand or contract based on the size of my grid as my UWP form is resized, etc. With a previous grid I simply set the width of all the static columns to a value and then set the column of my dynamic column to star. Star is not accepted by the column width property here and the size modes dont seem to have a value that accommodates this.
What am I missing?
7 Answers, 1 is accepted
As advised in the ticket you have raised, you can achieve the behavior by setting the following properties.
For the static columns:
For the dynamic ones:
Have a great rest of the week.
The solution work with expanding size.
But how is it possible to contract based on the size of the grid?
I need all columns except one to have SizeMode Auto. And one column to fill the rest place, not expanding if values are wider.
In order to have one column Stretch and the rest AutoSized you will need to place the RadDataGrid inside of a GridLayout, for example:
The SizeMode="Stretch" means that the column is stretched to the available width proportionally to its desired width. For more details on the DataGrid Column properties check our help article: DataGrid Columns Overview
I hope this will help.
No, it doesn't work.There is still horizontal scrolling. I need to avoid horizontal scrolling.
Here is an attached sample.
There are three columns in the grid. The first and the third ones must be always visible without horizontal scrolling. The column in the middle must take only available space, not wider.
I am sorry to hear that the provided solution didn't help.
By default the RadDataGrid Columns are sized in a way to visualize the content of the cell. As to the columns' sizing modes - indeed, when Stretched size mode is used, the column takes the available space, however it stretches in order to accommodate longer strings, thus pushing other columns off the visible area and causing horizontal scrolling.
You'd need to set fixed width to the second column as well taking into account the screen width (using SizeChanged, for example). At the moment, the only solution I could suggest is to use TemplateColumn instead of TextColumn and implement the above described logic, as in the template you could add a Label and set its LineBreakMode. Here is the snippet:
and the event handler:
Please note that TemplateColumn has some limitations compared to the built-in columns - for example, it does not support sorting, filtering and editing.
I guess you're using TextColumn with SizeMode set to Fixed - indeed, in that case, the text is not wrapped. We have a feature request regarding this functionality, please cast your vote and follow the public item below in order to get notified on status changes:
For the time being, as suggested below, you can use TemplateColumn and place it it a Label with LineBreakMode property applied.
I am sorry for any inconvenience caused. Let me know if I can assist with anything else.