HeaderStyle -TextWrapping to "Wrap"

4 posts, 0 answers
  1. veena
    veena avatar
    32 posts
    Member since:
    Mar 2009

    Posted 22 Sep 2009 Link to this post

    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
                       

  2. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 25 Sep 2009 Link to this post

    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.
  3. DevCraft banner
  4. veena
    veena avatar
    32 posts
    Member since:
    Mar 2009

    Posted 28 Sep 2009 Link to this post

    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

  5. veena
    veena avatar
    32 posts
    Member since:
    Mar 2009

    Posted 29 Sep 2009 Link to this post

    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

     

     

     


     

Back to Top