Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollViewer scrollbar always disabled

Tags:

wpf

xaml

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>

Does anyone know why?

EDIT:
Made it work like this:

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

        </ItemsControl>
    </ScrollViewer>
</DockPanel>
like image 319
Para Avatar asked May 16 '12 20:05

Para


1 Answers

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

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

like image 175
zduny Avatar answered Oct 13 '22 23:10

zduny