Question

I have a simple scrollviewer setup in my wpf application. Everything works fine, Now I want my scrollviewer's content should use the space of my the scollbar as well, As my scrollbar is transparent it could easily display the content.

Just like the scrollbars in facebook. Attached is the image of the output. Green Section is the content and red section is scollviewer's area.

enter image description here

I am using WrapPanel in my scrollviewer, this is the code snippet

<ScrollViewer x:Name="ScrollViewer1"                
              HorizontalScrollBarVisibility="Auto"                
              VerticalScrollBarVisibility="Hidden">
    <WrapPanel x:Name="WrapPanel1" SizeChanged="WrapPanel1_SizeChanged" />
</ScrollViewer>
Was it helpful?

Solution

You have to edit the ScrollViewer's ControlTemplate which should look like the one in this page : http://msdn.microsoft.com/en-us/library/aa970847(v=vs.110).aspx

In the ScrollViewer Control Template Example, you can see that the ScrollContentPresenter is inside a Border which is inside the first row of a 2-rows Grid.

Setting the RowSpan to 2 for this Border would achieve the effect you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top