This is a migrated thread and some comments may be shown as answers.

WordWrap in PanelBar

2 Answers 73 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Kakone
Top achievements
Rank 1
Kakone asked on 21 Jun 2010, 05:10 PM
Hello,

I have a panel bar like this :
<telerikNavigation:RadPanelBar DataContext="{Binding Menu}" ItemsSource="{Binding MenuItems}" SelectedItem="{Binding SelectedMenuItem, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="Disabled">                                            
  <telerikNavigation:RadPanelBar.ItemTemplate> 
    <telerik:HierarchicalDataTemplate ItemsSource="{Binding Items}"
      <StackPanel Orientation="Horizontal" > 
        <Image Source="{Binding Image, Converter={StaticResource BitmapImageConverter}}" Margin="5 3 5 3" /> 
        <TextBlock Text="{Binding Text}" VerticalAlignment="Center" TextWrapping="Wrap" /> 
      </StackPanel> 
    </telerik:HierarchicalDataTemplate> 
  </telerikNavigation:RadPanelBar.ItemTemplate> 
</telerikNavigation:RadPanelBar> 

All is perfect except the text wrapping. The text is always on one line.

An idea to accomplish this ?

Cordially,
Stephane.

2 Answers, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 24 Jun 2010, 02:40 PM
Hello Kakone,

The issue is caused by the StackPanel used in the DataTemplate. Since the StackPanel thinks its children have unlimited size no wrap is applied. However, you can replace it with a Grid with defined width for the TextBlock, like so:
<telerik:HierarchicalDataTemplate ItemsSource="{Binding Items}">
     <Grid >
        <Grid.ColumnDefinitions>
              <ColumnDefinition Width="Auto"/>
              <ColumnDefinition Width="200"/>
        </Grid.ColumnDefinitions>
        <Image Source="{Binding Image, Converter={StaticResource BitmapImageConverter}}" Margin="5 3 5 3" />
        <TextBlock Text="{Binding Text}" VerticalAlignment="Center" TextWrapping="Wrap" Grid.Column="1"/>
     </Grid>
</telerik:HierarchicalDataTemplate>
Give this approach a try and let me know if it works for you.

Greetings,
Tina Stancheva
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
0
Kakone
Top achievements
Rank 1
answered on 24 Jun 2010, 03:48 PM
Hello,

Indeed, I'm stupid (sorry :-)). With a grid, it works better.
As I don't want to fix the width, I do this :
<Grid.RowDefinitions> 
  <RowDefinition Height="Auto" /> 
  <RowDefinition Height="*" /> 
</Grid.RowDefinitions> 
 And it works fine !

Very thanks,
Kakone.
Tags
PanelBar
Asked by
Kakone
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Kakone
Top achievements
Rank 1
Share this question
or