HorizontalAlignment Problem

3 posts, 0 answers
  1. Levon
    Levon avatar
    17 posts
    Member since:
    May 2013

    Posted 17 May 2013 Link to this post

    I have aligned my RadPanelBar horizontally using the stretch property. So when my page loads, it is displayed as I want. But when I expand it clicking on the header, it grows bigger than my page size. To see the pictures of what I say you can visit here.
    The items that i load from database grow bigger than the pages' width, but my ItemsControl sits in a ScrollViewer, which horizontalalignment is set to stretch. My code is provided below:
            <DataTemplate x:Key="ContentTemplate">
                <ScrollViewer HorizontalAlignment="Stretch"
                    <ItemsControl x:Name="Test"
                                  ItemsSource="{Binding Items}"
                                <toolkit:WrapPanel Orientation="Vertical"
                                <controls:ParameterItem Style="{StaticResource ParamItem}" 
                                                        Description="{Binding Code}"
                                                        ParamValue="{Binding Value}"/>
        <Grid x:Name="LayoutRoot" Background="White">
          <telerik:RadBusyIndicator IsBusy="{Binding IsLoading}">
            <Grid Grid.Column="1">
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                <Grid HorizontalAlignment="Stretch" Height="28">
                        <ColumnDefinition />
                        <ColumnDefinition Width="90" />
                        <ImageBrush ImageSource="/ISDN.NSS.UI.Themes;component/Images/HeaderBG.png" />
                    <TextBlock Grid.Column="0" FontSize="13" FontWeight="Bold" VerticalAlignment="Center" FontFamily="Arial" Margin="8,0,0,0" Text="Model Parameters"></TextBlock>
                    <telerik:RadPanelBar Grid.Row="1"
                                         ItemsSource="{Binding Parameters}"
                            <telerik:HierarchicalDataTemplate ItemTemplate="{StaticResource ContentTemplate}"
                                                              ItemsSource="{Binding RootItems}">
                                <TextBlock Text="{Binding Name}"
    What do I do wrong?
  2. Tina Stancheva
    Tina Stancheva avatar
    3298 posts

    Posted 21 May 2013 Link to this post

    Hello Levon,

    The RadPanelBar has a built-in ScrollViewer and it is displayed as soon as the control can't properly display its content inside the available area. I believe this is exactly the case you've encountered. And if you need to display your ScrollViewer instead, then you can edit the default RadPanelBar ControlTemplate and remove the ScrollViewer element.

    Also please note that when you set the PanelBar HorizontalAlignment to Stretch, the control will take all available space but if its items need more space to display, it will try to expand further. And if your overall layout allows the control to take more space, then it will do so. In that case, you will have to either make sure the panel which hosts the control doesn't allow it to further expand (you can apply a MaxWidth or a Width on the column in which the RadPanelBar is displayed), or you need to specify the RadPanelBar Width property.

    I attached a sample solution where I removed the ScrollViewer element from the RadPanelBar ControlTemplate and I also placed the control in a Grid Column with predefined Width. Please have a look at the solution and let us know if you need more information.

    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. Levon
    Levon avatar
    17 posts
    Member since:
    May 2013

    Posted 22 May 2013 Link to this post

    Thank you Tina,
    the problem is solved.
Back to Top