5

I'm trying to make my scroll viewer scroll flawlessly, that is I have a scrollviewer and it contains a stackpanel , the stack panel contains a user-made user control. and they can increase or decrease dynamically at run time.

the problem is, suppose i have only 2 user controls in my stack panel , the scroll viewer have only 2 levels of scrolling, so it scrolls a whole user control for each click or mouse-wheel movement.

how can I change that? is it a property or there is a mistake in the design?

here is the xaml code for it:

<ScrollViewer HorizontalAlignment="Left" Height="420" VerticalAlignment="Top" Width="862" Margin="0,0,-2,0" CanContentScroll="True" PanningRatio="0.1">
                <StackPanel x:Name="hpList" HorizontalAlignment="Left" Height="422" VerticalAlignment="Top" Width="843"/>
            </ScrollViewer>

and the stack panel expands or shrinks dynamically.

3
  • 1
    Set CanContentScroll="False" and it will work magically. Commented Oct 31, 2013 at 8:55
  • now it can't scroll at all! Commented Oct 31, 2013 at 9:02
  • in addiotion to @devhedgehog now Try setting StackPanel with IsItemsHost="False" Commented Oct 31, 2013 at 9:09

1 Answer 1

7

set CanContentScroll="False" and remove the stackpanel height\width

Sign up to request clarification or add additional context in comments.

2 Comments

that did the trick! thanks , but can u explain what does the height\width has to do with it?
the stackpanel size go to the scroll content size so it seems to scrollviewer that he need no scroll, (if i'm unclear google is full of answers :) )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.