加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

.net – ScrollViewer中的ListBox

发布时间:2020-12-14 05:46:24 所属栏目:Windows 来源:网络整理
导读:我不知道为什么这段代码工作正常: ScrollViewer Height="674" HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Margin="0,94,0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" StackPanel Button Content
我不知道为什么这段代码工作正常:

<ScrollViewer Height="674" HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Margin="0,94,0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
    <StackPanel>
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
        <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
    </StackPanel>
</ScrollViewer>

这不是:

<ScrollViewer Height="674" HorizontalAlignment="Left" VerticalAlignment="Top" Width="480" Margin="0,0" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
    <ListBox Width="480" ItemsSource="{Binding ViewModel_ObservableCollection_Property_With_15_Items}">
        <ListBox.ItemTemplate>
            <DataTemplate>
                <Grid Height="85">
                    <Button Content="custom control" VerticalAlignment="Center" Width="480" Height="70" />
                </Grid>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</ScrollViewer>

ListBox版本无法显示ScrollViewer中的所有项目.诀窍是什么?

解决方法

您应该避免使用ScrollViewer来包装ListBox,因为在默认的ListBox样式中已经存在ScrollViewer.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读