Set line and page size for ScrollViewer - c#

Is it possible to set the number of logical units the ScrollViewer should scroll when either clicking the arrows of the scrollbar (line up, line down) or inside the scrollbar (page up, page down)?

You can try this:
ScrollBar verticalScrollBar = scrollViewer.Template.FindName("PART_VerticalScrollBar", scrollViewer) as ScrollBar;
verticalScrollBar.SmallChange = 5;
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/577fdd3a-e416-43ec-b2a0-9d36ba8be3f3/
Other than that, I can't find any out-of-the box solution without you rolling your own.
Wpf ScrollViewer Scroll Amount

Related

How to force the treeview's scrollbar to appear / expand?

Assume that treeview's Scrollable Property has been set to true correctly.
As the scrollbar appears only when the treenodes is out of the visible area. However, I want it to always showing a blank area below the buttom treenode(where treeViewHitTestInfo.Location == none), while the scrollbar will only expand pettily to show all the treenode. Sometimes, the lowest treenode(whose index is largest at root) only show about 40% of the label in the treeview, and EnsureVisible() don't work at all.
I tried SetScrollRange() in user32.dll to change the scrollbar's height. However, it doesn't work well. It seems that the treeview's "client area" is settled by the system's caculation using my nodes's height and unchangable for me.
Is there a way to force it to expand?

Controlling RichTextBox position with other ScrollBar

I have richTextBox (dock style = fill, scrollbar = only vertical, wordwrap = false) in splitcontainer.panel1
splitcontainer.panel1.Controls.Add(richTextBox);
In case when richTextBox needs to be scrolled (when its width is bigger than width of splitcontainer.panel1).
I wish a scrollbar would appear (but in splitcontainer.panel1, not scroll bar from richTextBox).
Is it possible to handle?
It certainly doesn't make sense to do that. For the sub-panel's scrollbars to even work properly, you couldn't dock-fill the RichTextBox control. Then you would have to constantly resize the RichTextBox control based on the TextChanged event, and that could get messy.
It's also not clear why you couldn't just set the ScrollBars to both:
richTextBox.ScrollBars = RichTextBoxScrollBars.Both;
It would seem to do the job you really want it to do.

Make vertical ScrollViewer invisible

I have a ScrollViewer control in my window and I would like to hide it when the user cannot scroll down the page. Just like with the horizontal scroll viewer. here is an example:
so here both scrollers are visible because scrolling is enabled:
if I collapse some of the columns of my listview note how eventually the horizontal scroller disappears:
Now note what happens with the vertical scroller:
so far its visible and that's ok because not all the content fits in the page. But let me maximize the page and co-lapse all the group boxes so that all the content fits in the page:
Why is it visible if it is not possible to scroll? I set all the group boxes height = 0 except the last one and the vertical scroller still shoes up? The horizontal scroller disappeared when it was not possible to scroll any more. Why does the vertical scroller does not behave the same way?
What can I do to make it invisible when it is not possible to scroll?
Make sure that your Scrollviewer's VerticalScrollBarVisibility = ScrollBarVisibility.Auto;

How to obtain visible borders of canvas placed on scrollviewer

I have canvas which is placed on scrollviewer in order to allow scrolling. Is it possible to get coordinates of visible part of canvas?
I was trying to calculate it that way
leftBorder = ScrollViewer1.HorizontalOffset;
rightBorder = ScrollViewer1.ViewportWidth - ScrollViewer1.HorizontalOffset;
topBorder = ScrollViewer1.VerticalOffset;
bottomBorder = ScrollViewer1.ViewportHeight - ScrollViewer1.VerticalOffset;
but it seems that it is not working.
The Horizontal and Vertical offset is the actual scroll value in that direction.
Besides that, if you want the size of the content without any scrollbars that might be visible.
You can search for the child named "PART_ScrollContentPresenter". This shows the actual content of the scrollviewer, and this content will be resized when the scrollbars needs more space.
Hope that helps.

WP7 ScrollViewer Snap-Back and Auto scrollbar visibility issues on windows phone

I have an application that displays wrapped text in a ScrollViewer that takes up a fixed height of the page. I set the HorizontalScrollBarVisibility to Disabled, and the VerticalScrollBarVisibility to Auto.
The usability problems I'm having are as follows:
Despite being set to Auto, if the content is smaller than the ScrollViewer, then the content can still scroll up and down, either scrolling past the end or hiding a portion of the text. I would like the ScrollViewer not to allow scrolling when the entire content fits inside its bounds. At the very least it should always snap the content back into view when you over-scroll.
Secondly, when the content does scroll, it sometimes gets stuck past the end and won't "snap back" from the over-scroll. For example, if the content fits fully in the ScrollViewer, and you drag your finger up or down on the text, the text will be obscured by the top or bottom of the ScrollViewer, and won't snap back. If however you drag your finger up starting from outside of the content of the ScrollViewer, it will snap back when you scroll past either end. I would like the "snap back" behavior to happen whether you drag on the content or outside of the content. Is that possible?
First issue: If your content isn't large enough to warrant the need for a scroll viewer don't put it in one. If the size of the content changes only enable the scrollbar when the volume of content warrants it.
Can you provide a way of reproducing the second issue.

Categories