Group header Text wrapping

6 posts, 1 answers
  1. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 19 Sep 2013 Link to this post

    Hi,

    How can I wrap texts in Group Headers?

    Thanks
  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 19 Sep 2013 Link to this post

    Hi Dani,

     

    The easiest way to achieve this result is to predefine GroupHeaderTemplate to a single column or to the whole RadGridView, as follows:

    <telerik:RadGridView  ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Property1}">
                    <telerik:GridViewDataColumn.GroupHeaderTemplate>
                        <DataTemplate>
                            <TextBlock Width="100" TextWrapping="Wrap" Text="Wrappppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp"/>
                            </DataTemplate>
                        </telerik:GridViewDataColumn.GroupHeaderTemplate>
                    </telerik:GridViewDataColumn>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>

    Regards,
    Vanya Pavlova
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 19 Sep 2013 Link to this post

    I mean Group fo RadTileList, not RadGridView


    thanks
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 19 Sep 2013 Link to this post

    Hello Dani,

    You can follow the exact same approach - set the TextWrapping property and desired Width to the TextBlock used as GroupTemplate. For example:

    <DataTemplate x:Key="groupTemplate">
                        <TextBlock  Text="{Binding}" TextWrapping="Wrap" />
                    </DataTemplate>
     
     
    <telerik:RadTileList x:Name="tileList"
                                 GroupTemplate="{StaticResource groupTemplate}" >
     

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Daní
    Daní avatar
    303 posts
    Member since:
    Feb 2008

    Posted 20 Sep 2013 Link to this post

    Hi Maya,

    I already tried this approach but it's not working. The only way I've found to wrap text in group header is by fixing TextBlock width. I have modified one of your demos to demonstrate the issue:

    <UserControl x:Class="RadTileList_Groups.MainPage"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                 xmlns:my="clr-namespace:RadTileList_Groups"
                 mc:Ignorable="d" d:DesignHeight="700" d:DesignWidth="700">
        <Grid>
            <Grid.Resources>
                <DataTemplate x:Key="GroupTemplate">              
                        <TextBlock Text="{Binding}"
                                   Margin="5,0,0,5"
                                   FontWeight="Bold" TextWrapping="Wrap"/>              
                </DataTemplate>
                <Style TargetType="telerik:Tile">
                    <Setter Property="Margin" Value="5,15,5,0"/>
                    <Setter Property="Background" Value="#A500AD"/>
                </Style>
            </Grid.Resources>
            <telerik:RadTileList x:Name="RadTileList"
                                 ScrollViewer.HorizontalScrollBarVisibility="Visible"
                                 GroupTemplate="{StaticResource GroupTemplate}" >
                <telerik:Tile Group="Continent very large, large large and large, and large, and large and dndnddndn" TileType="Single">
                    <TextBlock Text="Europe"/>
                </telerik:Tile>
                <telerik:Tile  Group="Country" TileType="Single">
                    <TextBlock Text="Germany"/>
                </telerik:Tile>
                <telerik:Tile Group="Continent" TileType="Single">
                    <TextBlock Text="Asia"/>
                </telerik:Tile>
                <telerik:Tile  Group="Country" TileType="Single">
                    <TextBlock Text="Italy"/>
                </telerik:Tile>
            </telerik:RadTileList>
        </Grid>
    </UserControl>
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 20 Sep 2013 Link to this post

    Hello Dani,

    TextWrapping will be applied when the space available for the TextBlock finishes. That being set, if TextBlock can stretch to infinity, the text will never be wrapped. In such cases, you need to set Width/ MaxWidth property. 

    Regards,
    Maya
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner