Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf ScrollViewer滚动条始终处于禁用状态_Wpf_Xaml - Fatal编程技术网

Wpf ScrollViewer滚动条始终处于禁用状态

Wpf ScrollViewer滚动条始终处于禁用状态,wpf,xaml,Wpf,Xaml,我是xaml和wpf的新手。 我试图将一些用户控件从代码隐藏插入到容器中。 我已在上阅读了此博客。 我尝试了那里使用的所有方法和其他一些方法,但滚动条从未启用。 我目前坚持的代码是: <DockPanel> <ScrollViewer HorizontalAlignment="Left" Margin="252,12,0,0"> <ItemsControl Name="captchaControls" Width="339" Height="

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

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

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

有人知道为什么吗

编辑:
让它像这样工作:

<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具有恒定的大小,无论其中包含什么


顺便说一句,你可能应该使用
x:Name
而不是
Name
,谷歌上的文章解释了原因。

好吧,是的,但是为了命名的目的,你应该坚持使用x:Name,因为有些对象可能没有Name属性。我不认为这有多大意义,它和写
这个一样毫无意义。*
,事实上更是如此,因为它甚至没有显示作用域之间的差异。