How to remove white space above and below the text in a GridViewCell

1 Answer 21 Views
GridView Styling
Jack
Top achievements
Rank 1
Jack asked on 28 Apr 2021, 10:22 PM | edited on 29 Apr 2021, 04:51 PM

Hello,

Please see the attached sample app for reference.

The issue is with the Crystal theme when I try to set the height of the row to 20 pixels in the grids and the height does change, however, it won't increase when a cell's text wraps. If you run the attached app you will see that behavior. 

The row height is set in App.xaml line 73. If you comment out that line you will see the functionality of the row height resize, but there is a lot of white space above and below the text in the grid. This is what I am trying to remove.

There is code I added to the App.xaml file at line 69 that sets the theme for the gridview to VisualStudio2019 that sets the row height the way I want it in the grids, however, if you comment that out and leave the line 73 uncommented, the row height for the grid does not increase with word wrapping in the cell. 

Is there a way to get the row height to have less white space and the row height to adjust with the word wrapping in the cells? 

Thanks,
Jack 

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko
Telerik team
answered on 03 May 2021, 09:41 AM

Hi Jack,

Thank you for the provided project.

I will start with that it is not recommended to mix NoXAML binaries with StyleManager. Mixing both styling mechanisms would lead to visual problems. I would suggest using NoXAML binaries to change the theme. You can merge the required assemblies at the top of the ResourceDictionary in App.xaml file.

Now to make the row height increase and see the whole text, you can set the RowHeight property of the RadGridVew. Setting the Height property to the GridViewRow directly will not respect the text inside the cells.

<Style TargetType="telerik:RadGridView" BasedOn="{StaticResource RadGridViewStyle}">
    <Setter Property="Foreground" Value="#333333" />
    <Setter Property="FontFamily" Value="{StaticResource sspBasicFontNameLight}" />
    <Setter Property="FrozenColumnsSplitterVisibility" Value="Collapsed" />
    <Setter Property="Margin" Value="4,0,8,8" />                
    <Setter Property="HorizontalContentAlignment" Value="Left" />
    <Setter Property="AlternationCount" Value="2" />
    <Setter Property="AlternateRowBackground" Value="{StaticResource sspRowBackGroundDark}" />
    <Setter Property="ShowGroupPanel" Value="False" />
    <Setter Property="ColumnWidth" Value="SizeToHeader" />
    <Setter Property="AutoGenerateColumns" Value="False" />
    <Setter Property="CanUserFreezeColumns" Value="False" />
    <Setter Property="RowIndicatorVisibility" Value="Collapsed" />
    <Setter Property="RowHeight" Value="20"/>
    <!--<Setter Property="telerik:StyleManager.Theme" Value="VisualStudio2019" />-->
</Style>

I hope this information is helpful.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Jack
Top achievements
Rank 1
commented on 03 May 2021, 03:23 PM

Thank you Dinko,
I will have to keep that in mind. And I thought it had to do with how the nested controls were interacting.
Take care,
Jack
Tags
GridView Styling
Asked by
Jack
Top achievements
Rank 1
Answers by
Dinko
Telerik team
Share this question
or