0

我有这个

        <ListBox  
                ItemsSource="{Binding Students}" 
                SelectionMode="Extended" 
                Name="listStudents" 
                Height="430" 
                IsEnabled="{Binding CanUpdateNumber}">
         </ListBox>

当 IsEnabled 为 true 并且列表框中的项目更多时,则存在垂直滚动条。当 IsEnabled 为假时,所有项目都被禁用(这是真的)并且滚动条关闭,因此无法看到列表框中的所有项目。

当 IsEnabled 为 false 时,如何使滚动条出现

4

1 回答 1

1

尝试使用 ScrollViewer 控件包装您的 ListBox,如下所示:

 <ScrollViewer VerticalScrollBarVisibility="Auto" Height="430" Width="110" Padding="0">
    <ListBox 
        ItemsSource="{Binding Students}" 
        SelectionMode="Extended" 
        Name="listStudents" 
        IsEnabled="{Binding CanUpdateNumber}"
        ScrollViewer.VerticalScrollBarVisibility="Hidden" 
        BorderThickness="0">
    </ListBox>
 </ScrollViewer>

在这里找到:http: //manny-grewal.blogspot.be/2010/09/enable-scroll-in-disabled-listbox-in.html

编辑:

我想我发现了我在这篇文章中犯的错误。在 Scrollviewer 中设置高度并从 ListBox 中移除高度。

于 2013-02-13T07:13:42.897 回答