This is a migrated thread and some comments may be shown as answers.

Change Header row Height when using wrap text

5 Answers 413 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 13 Jul 2010, 06:46 PM

How do you make the Header Row height autosize or even manually set it, when using Word Wrap and forcing the Header to wrap to 2 lines.
Below is a sample of the XAML, just one column that has wrap enabled. It looks correct in .NET VS2008 designer, but when running it the height of the header row is not tall enough and the 2nd line of text is cut in half.

I've looked on the forums and see some examples, but they seem very difficult to implement using a Resouce.xaml file. It seems like it should be more straightforward.

Thanks ... Chad

<Telerik:RadGridView SelectionMode="Single"                                                 
                     CanUserDeleteRows="False"
                     CanUserSortColumns="True"                                                 
                     AutoGenerateColumns="False"
                     IsFilteringAllowed="False"
                     CanUserReorderColumns="False"
                     RowDetailsVisibilityMode="VisibleWhenSelected"
                     Telerik:StyleManager.Theme="Office_Blue"
                     ShowGroupPanel="False"
                       
                     ItemsSource="{Binding Path=GetData,Mode=TwoWay}"
                     IsReadOnly="False" >
    <Telerik:RadGridView.Columns>
          
          
        <Telerik:GridViewDataColumn IsReadOnly="True"
                                    Width="90" UniqueName="Level1GuaranteedPercent" >
            <Telerik:GridViewDataColumn.DataMemberBinding>
                <Binding Path="Level1GuaranteedPercent">
                </Binding>
            </Telerik:GridViewDataColumn.DataMemberBinding>
            <Telerik:GridViewColumn.Header>
                <TextBlock Text="Level 1 Past Purchase %" TextWrapping="Wrap" />
            </Telerik:GridViewColumn.Header>
        </Telerik:GridViewDataColumn>
    </Telerik:RadGridView.Columns>
</Telerik:RadGridView>

5 Answers, 1 is accepted

Sort by
0
Ваня
Top achievements
Rank 1
answered on 13 Jul 2010, 06:54 PM
Hi,Chad 

Did you see that:http://blogs.telerik.com/blogs/posts/09-02-03/easy_programmatic_ui_customization_for_wpf_and_silverlight.aspx ?
Just for reference:

14) Increase header row Height: 
   
var headerRow = RadGridView1.ChildrenOfType<GridViewHeaderRow>().First(); 
   headerRow.Height = 100; 


On the other hand-you can set the TextWrapping property to WrapWithOverflow!
Hope this,helps!
0
Ваня
Top achievements
Rank 1
answered on 13 Jul 2010, 07:16 PM
Hi,Chad

I am sorry for this post again but I tried ti reproduce this on my behalf-everything works fine even with TextWrapping set to Wrap or to WrapWithOverflow......
0
Chad
Top achievements
Rank 1
answered on 15 Jul 2010, 02:47 PM
Vanya ROCKS!!!!

Perfect!!! Yes I was able to use your recommended code and it worked.

Still disappointed that there wasn't a property in the XAML to autosize the height or that it was not intelligent enough to do it on by itself.

Thanks again Vanya and for the extra steps of finding the previous thread reference.

0
Lynne
Top achievements
Rank 1
answered on 10 Nov 2011, 11:09 PM
I can't find a property that allows setting the TextWrapping property for GridViewHeaderCells.

It seems to apply to Columns, but GridViewHeaderRows don't have a Column collection.

I can set the height of my GVHR just fine, but now I want to set the TextWrapping property for the cells/columns in it.  How do I do that?

0
Vanya Pavlova
Telerik team
answered on 11 Nov 2011, 01:37 PM
Hi Lynne,

 

The easiest way to enable TextWrapping is to define your own Header and set the TextWrapping to the corresponding element.  In our online documentation we have an article which demonstrates how this can be achieved, you may find it here.  The other option is to predefine the template of GridViewHeaderCell and enable the TextWrapping from there. 



Kind regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Chad
Top achievements
Rank 1
Answers by
Ваня
Top achievements
Rank 1
Chad
Top achievements
Rank 1
Lynne
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Share this question
or