Click here to Skip to main content
15,884,537 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" >
                            <ListView.Template>
                                <ControlTemplate>
                                    <Border CornerRadius="3" BorderThickness="1" BorderBrush="LightGray" Background="{TemplateBinding Background}">
                                        <ItemsPresenter></ItemsPresenter>
                                    </Border>
                                </ControlTemplate>
                            </ListView.Template>
                            <ListView.ItemContainerStyle>
                                <Style TargetType="{x:Type ListViewItem}">
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type 
                                                ListViewItem}">
                                                <Border x:Name="Border" 
                                                BorderBrush ="LightGray" 
                                                 BorderThickness="0 0 0 1">
                                                    <ContentPresenter />
                                                </Border>
                                                <ControlTemplate.Triggers>
                                                    <Trigger Property="IsMouseOver" 
                                                     Value="True">
                                                        <Setter 
                                                        Property="Background" 
                                                        TargetName="Border" 
                                                        Value="#FF5DD4F2">
                                                    </Setter>
                                                    </Trigger>
                                                    <Trigger Property="IsSelected" 
                                                     Value="True">
                                                        <Setter  
                                                     Property="Background" 
                                                     TargetName="Border" Value="#FF3266A0"></Setter>
                                                        <Setter Property="Foreground" Value="White"></Setter>
                                                    </Trigger>
                                                </ControlTemplate.Triggers>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </ListView.ItemContainerStyle>
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <WrapPanel>
                                        <TextBlock Text="{Binding Bez}" />
                                        <TextBlock Text=" (" />
                                        <TextBlock Text="{Binding ArtNr}" />
                                        <TextBlock Text=" | " />
                                        <TextBlock Text="{Binding SlNr}"/>
                                        <TextBlock Text=")" />
                                    </WrapPanel>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>
                    </Grid>


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

What I have tried:

ScrollViewer.CanContentScroll = true
Posted
Updated 19-Jun-17 5:52am
v2
Comments
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:
XAML
<ListView.Template>
    <ControlTemplate>
        <Border CornerRadius="3" BorderThickness="1" BorderBrush="LightGray" Background="{TemplateBinding Background}">
            <ScrollViewer Padding="{TemplateBinding Padding}" Focusable="False">
                <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </ScrollViewer>
        </Border>
    </ControlTemplate>
</ListView.Template>
 
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