ScrollViewer scroll bar always off

I am new to xaml and wpf.
I am trying to insert some user controls into a container from code. I read this MSDN blog post .
I tried all the methods used there, and some others, but the scroll bar was never included.
My current code I'm stuck is this:

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

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

Does anyone know why?

EDIT:
Did it like this:

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

        </ItemsControl>
    </ScrollViewer>
</DockPanel>
+3
source share
1 answer

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

BTW. You should probably use google x:Nameinstead Namefor articles explaining why.

+3

All Articles