Click here to Skip to main content
13,202,820 members (55,723 online)
Rate this:
 
Please Sign up or sign in to vote.
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 18-Jun-17 23:33pm
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

You need a ScrollViewer in your control template:
<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>
  Permalink  

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


Advertise | Privacy |
Web02 | 2.8.171020.1 | Last Updated 19 Jun 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100