Click here to Skip to main content
15,947,476 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I got this XAML for my ListView:

<Grid x:Name="gSearch"  Grid.Row="1" Margin="0,45,871,0" >
                        <ListView x:Name="lVsearch" Height="472" Margin="15,7,5,17" SelectionMode="Single" 
                                      HorizontalContentAlignment="Stretch" ScrollViewer.CanContentScroll="True" >
                                    <Border CornerRadius="3" BorderThickness="1" BorderBrush="LightGray" Background="{TemplateBinding Background}">
                                <Style TargetType="{x:Type ListViewItem}">
                                    <Setter Property="Template">
                                            <ControlTemplate TargetType="{x:Type 
                                                <Border x:Name="Border" 
                                                BorderBrush ="LightGray" 
                                                 BorderThickness="0 0 0 1">
                                                    <ContentPresenter />
                                                    <Trigger Property="IsMouseOver" 
                                                    <Trigger Property="IsSelected" 
                                                     TargetName="Border" Value="#FF3266A0"></Setter>
                                                        <Setter Property="Foreground" Value="White"></Setter>
                                        <TextBlock Text="{Binding Bez}" />
                                        <TextBlock Text=" (" />
                                        <TextBlock Text="{Binding ArtNr}" />
                                        <TextBlock Text=" | " />
                                        <TextBlock Text="{Binding SlNr}"/>
                                        <TextBlock Text=")" />

i don't know why the ListView is not showing the ScrollBars?

What I have tried:

ScrollViewer.CanContentScroll = true
Updated 19-Jun-17 5:52am
Richard MacCutchan 19-Jun-17 7:13am    
Does the list contain enough items to require a scrollbar?
Member 12969975 19-Jun-17 7:23am    
for sure, it just go further in the list but without the scrollbars :(
George Swan 19-Jun-17 12:38pm    
Try this. Wrap a ScrollViewer around the ListView. Set the Margin and Height inside the ScrollViewer tag and remove the Margin and Height references from the ListView as well as the ScrollViewer.CanContentScroll="True" reference.

1 solution

You need a ScrollViewer in your control template:
        <Border CornerRadius="3" BorderThickness="1" BorderBrush="LightGray" Background="{TemplateBinding Background}">
            <ScrollViewer Padding="{TemplateBinding Padding}" Focusable="False">
                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900