How to make scrollviewer scroll pixels not components (wpf)

与世无争的帅哥 提交于 2019-12-01 23:20:10

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/19701831/how-to-make-scrollviewer-scroll-pixels-not-components-wpf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!