gpt4 book ai didi

c# - 没有为 ListView 启用 ScrollViewer

转载 作者:太空狗 更新时间:2023-10-29 23:09:58 26 4
gpt4 key购买 nike

我在 UserControl 中有一个 ListView 控件。但是,当内容溢出 ListView 的大小时,垂直 ScrollBar 不会启用,尽管在 XAML 中进行了设置。

enter image description here

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>

我还尝试将 ListView 分组到 ScrollViewer 中,但仍然不起作用。

非常感谢您:)

最佳答案

这看起来像

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

所以我会假设容器有问题,因为它没有限制 ListView 的大小,你把它放在哪里了?确保容器布局控件时有限制。

关于c# - 没有为 ListView 启用 ScrollViewer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9066497/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com