Wrap the text in all the columns header using style xaml

2 posts, 0 answers
  1. Will
    Will avatar
    7 posts
    Member since:
    May 2014

    Posted 03 Sep 2015 Link to this post

    I don't know how to wrap columns header using just a style. I cannot use code behind because we don't have code behind. We use MVVM and CaliburnMicro so we don't have code behind the view. So I was trying to apply style to the grid and wrap all the headers every time I add grid to the form but I cannot accomplish this task. I don't want to do wrap to every column every time I add the grid. So my Idea was but it doesn't work. Please advice.

    <Style TargetType="telerik:GridViewDataColumn" >
            <Setter Property="Header">
                <Setter.Value>
                    <DataTemplate>
                        <TextBlock TextWrapping="Wrap" Text="{Binding}"></TextBlock>
                    </DataTemplate>
                </Setter.Value>
          </Setter>
     </Style>

     Thank you,

    Grazyna

     

     

  2. Yoan
    Admin
    Yoan avatar
    1068 posts

    Posted 04 Sep 2015 Link to this post

    Hello Grazyna,

    You can easily achieve the desired behavior by using the following style:
    <telerik:RadGridView.Resources>
                    <Style TargetType="telerik:GridViewHeaderCell">
                        <Setter Property="ContentTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <TextBlock Text="long long logn text" TextWrapping="Wrap" />
                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </telerik:RadGridView.Resources>


    Regards,
    Yoan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top