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:RadPanelBar>
            <telerikPanel:RadPanelBarItem x:Name="CommentsItems" IsExpanded="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
                <telerikPanel:RadPanelBarItem.Header>
                    <TextBlock Text="Header" TextTrimming="WordEllipsis" VerticalAlignment="Center"/>
                </telerikPanel:RadPanelBarItem.Header>
                <Grid Margin="2" >
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="30" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <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">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                            <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="*" />
                                                    </Grid.ColumnDefinitions>
                                                    <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" />
                                                    </Border>
                                                        <TextBlock Text="{Binding TextA}" />
                                                        <Border x:Name="HoverBorderControl" Grid.ColumnSpan="2" Visibility="Collapsed" 
                                                                HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinHeight="22">
                                                        <Grid >
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="22" />
                                                                <ColumnDefinition Width="*" />
                                                            </Grid.ColumnDefinitions>
     
     
                                                            <Button ToolTipService.ToolTip="Edit" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,2,0,0" >
                                                                        <TextBlock Text="Edit" />
                                                            </Button>
                                                            <Button ToolTipService.ToolTip="Delete" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,0,0" >
                                                                        <TextBlock Text="Delete" />
                                                            </Button>
                                                        </Grid>
                                                    </Border>
                                                </Grid>
                                            </Border>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
     
                        </StackPanel>
                    </ScrollViewer>
                        <Button x:Name="AddUpdateButton" ToolTipService.ToolTip="Add New" Width="40" HorizontalAlignment="Left" Grid.Row="1" >
                                    <TextBlock Text="Add"/>
                        </Button>
                </Grid>
     
            </telerikPanel:RadPanelBarItem>
    </telerikPanel:RadPanelBar>

    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. DevCraft banner
  4. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 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