Showing Vertical & Horizontal ScrollBar in a ListBox

4 posts, 1 answers
  1. Hela
    Hela avatar
    4 posts
    Member since:
    Jan 2009

    Posted 05 Feb 2009 Link to this post

    Hi,
    I've a Border that contains a StackPanel with a ListBox .But, I can't Show Vertical & Horizontal ScrollBar in a ListBox even if I wrote

    ScrollViewer.HorizontalScrollBarVisibility

    ="Auto"

     

     

    ScrollViewer.VerticalScrollBarVisibility="Auto"

     


    Can someone please give me a solution for that?
    thanks a lot,
    Héla
  2. Answer
    Hristo
    Admin
    Hristo avatar
    832 posts

    Posted 06 Feb 2009 Link to this post

    Hello Hela,

    Remove the StackPanel and you will see the ScrollBars (if you have more items then available space).
    The StackPanel is measuring with Infinity (depending on Orientation property) so ScrollViewer will think that he have enough space and will not show the ScrollBars.

    Let me know if you need more help.

    Kind regards,

    Hristo
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Hela
    Hela avatar
    4 posts
    Member since:
    Jan 2009

    Posted 07 Feb 2009 Link to this post

    Hi Hristo,
    Thanks a lot for your answer.It's just what I needed!
    Hope good work for you,
    Héla
  4. Hardik
    Hardik avatar
    11 posts
    Member since:
    Jun 2012

    Posted 22 Aug 2012 Link to this post

    Hii,

    I am facing a similar issue, but even after removing the Stack Panel, I am not able to view scrollviewer.

    <UserControl.Resources>
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
            <telerik:RadWrapPanel Width="610" Height="300" />
        </ItemsPanelTemplate>
        <DataTemplate x:Key="DataTemplate1">
            <Border BorderBrush="#cecfce" BorderThickness="1">
                <StackPanel Orientation="Horizontal" Width="200" Height="24" >
                    <TextBlock Text="{Binding Path=Name}" Margin="5,0,0,0" VerticalAlignment="Center" ></TextBlock>
                </StackPanel>                          
            </Border>
        </DataTemplate>
    </UserControl.Resources>
     
    <Grid x:Name="LayoutRoot" Background="White" Margin="50,50,50,0">
        <telerik:ListBox ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" x:Name="list" MaxHeight="300" Grid.Row="0" Grid.Column="0"  VerticalAlignment="Top" ItemsPanel="{StaticResource ItemsPanelTemplate1}" ItemTemplate="{StaticResource DataTemplate1}">
        </telerik:ListBox>         
    </Grid>
Back to Top