Text Wrapping

3 posts, 0 answers
  1. Stanescu Mihai
    Stanescu Mihai avatar
    33 posts
    Member since:
    Aug 2009

    Posted 21 Oct 2010 Link to this post

    Hello, i would appreciate some help on this matter. I am using you panelbar which is great but I do have an issue. 
    So this is my basic code:

            <telerikPanel:RadPanelBarItem x:Name="CommentsItems" IsExpanded="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                    <TextBlock Text="Header" TextTrimming="WordEllipsis" VerticalAlignment="Center"/>
                <Grid Margin="2" >
                        <RowDefinition Height="*" />
                        <RowDefinition Height="30" />
                    <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="Content:"/>
                            <ListBox VerticalAlignment="Stretch" MinHeight="22" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                                            <Border HorizontalAlignment="Stretch" Background="White"  VerticalAlignment="Stretch"
                                                          MouseEnter="Grid_MouseEnter" MouseLeave="Grid_MouseLeave" MinHeight="22">
                                                <Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                                              x:Name="ItemGrid" MinHeight="22">
                                                    <Grid.ColumnDefinitions >
                                                        <ColumnDefinition Width="70"/>
                                                        <ColumnDefinition Width="*" />
                                                    <Border x:Name="rtbContent"  Grid.Column="1" HorizontalAlignment="Stretch"  VerticalAlignment="Stretch">
                                                        <TextBlock x:Name="Title" Text="{Binding Title}" Grid.Column="1" TextWrapping="Wrap" VerticalAlignment="Stretch" />
                                                        <TextBlock Text="{Binding TextA}" />
                                                        <Border x:Name="HoverBorderControl" Grid.ColumnSpan="2" Visibility="Collapsed" 
                                                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="22">
                                                        <Grid >
                                                                <ColumnDefinition Width="22" />
                                                                <ColumnDefinition Width="*" />
                                                            <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,2,0,0" >
                                                                        <TextBlock Text="Edit" />
                                                            <Button ToolTipService.ToolTip="Delete" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,0,0" >
                                                                        <TextBlock Text="Delete" />
                        <Button x:Name="AddUpdateButton" ToolTipService.ToolTip="Add New" Width="40" HorizontalAlignment="Left" Grid.Row="1" >
                                    <TextBlock Text="Add"/>

    My problem is that the textblock which binds to Title doesn't wrap, and it is a really long string. Is there something i missed?
  2. Stanescu Mihai
    Stanescu Mihai avatar
    33 posts
    Member since:
    Aug 2009

    Posted 22 Oct 2010 Link to this post

    So for anyone who hits this issue i have solved it, the problem was the stackpanel inside the scrollviewer. Weird cause it's orientation is set to vertical, doesn't this mean that it can expand to infinity on the vertical? 
  3. Petar Mladenov
    Petar Mladenov avatar
    2986 posts

    Posted 25 Oct 2010 Link to this post

    Hello Stanescu Mihai,

    Initially, the StackPanel and the Grid control have both Width and Height properties set to infinity . This means that the controls inside Grid and StackPanel can expand to infinity in both directions: horizontal and vertical.
    Properly working wrapping of text  in TextBlock requires a parent container that has width set to some value different from infinity. In your case you can set the Width of a StackPanel or a Grid that contains the TextBlock bounded to "Title". Another workaround could be setting the Width of the RadPanelBaritem.

    Hope this information was useful for you. I would be glad if I can assist you further.  

    All the best,
    Petar Mladenov
    the Telerik team
    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 Public Issue Tracking system and vote to affect the priority of the items
Back to Top