ScrollViewer未启用ListView

Mar*_*hal 5 c# wpf xaml listview scrollview

ListView里面有一个控件UserControl.但是当内容溢出的大小时,尽管在XAML中设置了ListViewvertical ScrollBar,但仍未启用vertical .

在此输入图像描述

XAML如下所示:

<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>
Run Code Online (Sandbox Code Playgroud)

我也尝试将ListView内部分组ScrollViewer,但仍然无法正常工作.

非常感谢你提前:)

H.B*_*.B. 6

这看起来像

  1. ListView占用了所有项目所需的所有空间,因此滚动被禁用.
  2. ListView超出其容器的界限.

所以我认为容器有错误,因为没有限制ListView的大小,你把它放在哪里?确保容器有限制地布置控件.