ScrollViewer 滚动条始终禁用 [英] ScrollViewer scrollbar always disabled

查看:37
本文介绍了ScrollViewer 滚动条始终禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 xaml 和 wpf 的新手.
我正在尝试从代码隐藏中将一些用户控件插入到容器中.我在 MSDN.
我尝试了那里使用的所有方法和其他一些方法,但从未启用滚动条.
我目前坚持使用的代码是:

I am new to xaml and wpf.
I am trying to insert some user controls into a container from the code-behind. I have read this blog entry on MSDN.
I tried all the methods used there and some others but the scroll bar is never enabled.
My current code that I stuck with is this:

<DockPanel>
    <ScrollViewer HorizontalAlignment="Left" Margin="252,12,0,0">
        <ItemsControl Name="captchaControls" Width="339" Height="286">

        </ItemsControl>
    </ScrollViewer>
</DockPanel>

有人知道为什么吗?


让它像这样工作:


Made it work like this:

<DockPanel>
    <ScrollViewer HorizontalAlignment="Left" Margin="252,12,0,0" Width="339" Height="286">
        <ItemsControl Name="captchaControls">

        </ItemsControl>
    </ScrollViewer>
</DockPanel>

推荐答案

从 XAML 中删除 Width="339" Height="286".它会导致 ItemsControl 具有恒定大小,无论其内部是什么.

Remove Width="339" Height="286" from XAML. It causes ItemsControl to have constant size no matter what is inside it.

顺便说一句.您可能应该使用 x:Name 而不是 Name,谷歌搜索解释原因的文章.

BTW. You should probably use x:Name instead of Name, google for articles explaining why.

这篇关于ScrollViewer 滚动条始终禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆