Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollViewer not enabled for ListView

I have a ListView control inside UserControl. But when content overflows size of the ListView, vertical ScrollBar is not enabled, despite of setting it in XAML.

enter image description here

XAML appears as follows:

<UserControl x:Class="GrandSuccessProject.View.ContactsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="367" d:DesignWidth="548" Background="{x:Null}" VerticalContentAlignment="Top">

<ListView ScrollViewer.CanContentScroll="True" 
          ScrollViewer.VerticalScrollBarVisibility="Visible" 
          ItemsSource="{Binding SelectedContacts}"  
          ItemContainerStyle="{StaticResource ContainerStyle}" 
          Grid.Row="1" 
          VerticalAlignment="Top" 
          VerticalContentAlignment="Top" />      
   
</UserControl>

I also tried grouping the ListView inside a ScrollViewer, but still doesn't work.

Thank you very much in advance :)

like image 761
Marshal Avatar asked Jan 30 '12 15:01

Marshal


1 Answers

This looks like

  1. The ListView taking all the space it needs for all the items, hence the scrolling is disabled.
  2. The ListView exceeding its container's bounds.

So i would assume that the container is at fault for not restricting the size of the ListView, where did you place it? Make sure the container lays out the controls with limitations.

like image 155
H.B. Avatar answered Oct 20 '22 15:10

H.B.