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>
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:Nameinstead ofName, google for articles explaining why.