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

HeaderStyle -TextWrapping to "Wrap"

3 Answers 93 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
veena
Top achievements
Rank 1
veena asked on 22 Sep 2009, 12:42 PM

Hi,

We are using the RadGridView in one of the XAML file. The column is a templated one with ControlTemplate set. Its a checkbox control used. The headertext of this gridViewDatacolumn is lengthy that the column is taking much space. Can you help me to have Header TextWrapping set so that the header text appears in 2 rows.I have already tried :
 <telerik:GridViewDataColumn.HeaderCellStyle>
                        <Style TargetType="GridView:GridViewHeaderCell">
                            <Setter Property="TextWrapping" Value="NoWrap" />
                        </Style>
                    </telerik:GridViewDataColumn.HeaderCellStyle>
I have placed this tag inside the <GridViewDataColumn> tag. But this is not working.

Please guide me in this.

Thanks in advance

VR
                   

3 Answers, 1 is accepted

Sort by
0
Stefan Dobrev
Telerik team
answered on 25 Sep 2009, 10:28 AM
Hi veena,

Please check out this forum post which has an example how to achieve this functionality.

All the best,
Stefan Dobrev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
veena
Top achievements
Rank 1
answered on 28 Sep 2009, 03:09 PM
I have already downloaded the code from the post. But the textwrapping is not occuring and the whole text is displayed in a single line in the header. Actually we are having a column which is a checkbox templated column. The header for this column is very lengthy that it looks odd when the actual width for occupying the checkbox control is very small.

Please advice on this. I have tried out all sample codes given the post where the sample application is loaded.

This is the sample code we have given for setting the style of the GridViewColumn under Resources tag.
<Style x:key="abc"
targettype="RadGridView:GridViewCell">
<Setter property="Template">
<Setter.value>
<ControlTemplate TargetType="RadGridView:GridViewCell">
<Border ....>
<CheckBox>...</Checkbox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

This is the code we have given inside the GridView for the column with style value set.

<RadGrid:GridViewDatacolumn x:Name="def" UniqueName="Address" ..CellStyle={StaticResource abc">

The header text for the column is set from a file so not given in XAML file.

 

 Please advice
Thanks in advance


VR

0
veena
Top achievements
Rank 1
answered on 29 Sep 2009, 08:43 AM
Hi,

I got the solution for this and now its working perfectly.

Method :

Create a style for the headerCell of the grid column for which we want the wrapping to true.

 

 

<Style x:Key="WrapStyle"

 

 

TargetType="RadGridView:GridViewHeaderCell">

 

 

 

<Setter Property="Template">

 

 

 

<Setter.Value>

 

 

 

<ControlTemplate TargetType="RadGridView:GridViewHeaderCell">

 

 

 

<Border BorderThickness="{TemplateBinding BorderThickness}"

 

 

BorderBrush="{TemplateBinding BorderBrush}"

 

 

Background="{TemplateBinding Background}">

 

 

 

<StackPanel>

 

 

 

<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="Wrap" Text="Sample text. This consists of enough text for wrapping for column width more than 150">

 

 

 

</TextBlock>

 

 

 

</StackPanel>

 

 

 

</Border>

 

 

 

</ControlTemplate>

 

 

 

</Setter.Value>

 

 

 

</Setter>

 

After setting the style we have to set the following for the GridColumn for which we want the style be applied.

<GridViewDataColumn x:Name="Address".....HeaderCellStyle="{StaticResource WrapStyle}" Width="150"/>

Thats it.. it will start working fine. Hope this will help others who is facing the issue.


VR

 

 

 


 

Tags
Calendar
Asked by
veena
Top achievements
Rank 1
Answers by
Stefan Dobrev
Telerik team
veena
Top achievements
Rank 1
Share this question
or