Bug with setting Grid Width?

2 Answers 101 Views
Styling
Peter
Top achievements
Rank 1
Iron
Peter asked on 27 Feb 2024, 10:30 PM

Hello. I am trying to figure out what and why my controls are getting their widths blown out to infinity, which has the negative effect of making one of my telerik:RadGridViews not show the complete grid cause it's off the form.

I have tried setting up my project with both Telerik.UI.for.Wpf.10.Xaml and without (for NoXaml) and both show the bad behaviour. What I'm seeing is, as soon as I add a vertical scrollbar around my Grid, then all the containing widths are suddenly blown out to infinity. HUH? Why is that?

I've attached what I'm seeing. I think this is a bug. If it's not, I am not sure what I am doing wrong? I simply started to try playing with styles, and this happens to my ScrollViewer? Doesn't seem right.

 

2 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
Iron
answered on 27 Feb 2024, 11:03 PM
I was able to figure a work around, but I feel this is more a hack than a real solution. I had to bind the width to the ActualWidth of a parent control. Seems cludgy to me, but it's working for now.
0
Stenly
Telerik team
answered on 01 Mar 2024, 01:00 PM

Hello Peter,

Placing elements inside a ScrollViewer will measure them with infinity, which is the observed behavior on your end when placing a RadGridView inside of it. Please note that when the RadGridView control is placed in elements that measure it with infinity, its UI virtualization logic will be turned off resulting in a reduced performance. Such elements are the ScrollViewer, StackPanel, as well as a Grid's ColumnDefinition/RowDefinition with Width/Height set to Auto.

The solution for preventing the observed behavior would be to set a fixed width on the RadGridView or bind it to the ActualWidth property, for example, of the parent ScrollViewer. Alternatively, as you have done in your latest answer, would be to set a fixed width to the parent Grid layout, which will also set the width of the RadGridView.

I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Styling
Asked by
Peter
Top achievements
Rank 1
Iron
Answers by
Peter
Top achievements
Rank 1
Iron
Stenly
Telerik team
Share this question
or