Is there a way to hide these arrows in a scrollbar of a scrollviewer?
I couldn't find anything on google on how to disable these, if that's not possible then is there a way to change their color?
You need to set the VerticalScrollBarVisibility property of your ScrollViewer. The options are
Auto - A ScrollBar appears and the dimension of the ScrollViewer is applied
to the content when the viewport cannot display all of the content.
For a horizontal ScrollBar, the width of the content is set to the
ViewportWidth of the ScrollViewer. For a vertical ScrollBar, the
height of the content is set to the ViewportHeight of the
ScrollViewer.
Disabled - A ScrollBar does not appear even when the viewport cannot display all of the content. The dimension of the content is set to the corresponding dimension of the ScrollViewer parent. For a horizontal ScrollBar, the width of the content is set to the ViewportWidth of the ScrollViewer. For a vertical ScrollBar, the height of the content is set to the ViewportHeight of the ScrollViewer.
Hidden - A ScrollBar does not appear even when the viewport cannot display all of the content. The dimension of the ScrollViewer is not applied to the content.
Visible - A ScrollBar always appears. The dimension of the ScrollViewer is applied to the content. For a horizontal ScrollBar, the width of the content is set to the ViewportWidth of the ScrollViewer. For a vertical ScrollBar, the height of the content is set to the ViewportHeight of the ScrollViewer.
Related
Basically I need to know the ScrollViewer ScrollBar width.
This answer How to find Vertical Scrollbar width of a Scrollviewer in C#
doesn't work
SystemParameters.VerticalScrollBarWidth
Any clue?
I found solution here Changing the width of a vertical scrollbar
ScrollBar vertical = ((FrameworkElement)VisualTreeHelper.GetChild(scrollviewer1, 0)).FindName("VerticalScrollBar") as ScrollBar;
var w = vertical.Width;
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;
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.
How can I remove the small rectangle that appears when a horizontal and vertical scrollbar appear?
I assume you are using a ScrollViewer. The default template of a ScrollViewer is a Grid containing two rows and two columns. The upper left cell contains the ScrollViewer content, upper right the vertical ScrollBar, lower left the horizontal ScrollBar, and a Rectangle on the lower right cell. Please check this article: http://www.eggheadcafe.com/tutorials/aspnet/f51ddf8c-5227-4f1b-a5df-ec3d1b3439ca/styling-the-wpf-scrollviewer.aspx. You can see the default template there. You could remove the rectangle and then set either the ColumnSpan of the horizontal ScrollBar or RowSpan of the vertical ScrollBar to cover the lower right cell. Hope this helps.
I'm using a ScrollViewer to display an Image. The Image has a ScaleTransform set as one of it's LayoutTransforms. I've got it setup to fit the width of the image into the ActualSize of the ScrollViewer. My problem is that if the image height requires the vertical scrollbar to be present (I have it set to Auto) then my image is scaled just a little bit to much. I know how to determine if the scrollbar would be present and how to get the correct scale, but I cannot figure out how to determine what the actual width of the scrollbar is. I guess I could just guess at it, but I'd like something that would work if I later add styles to my application that would result in the scrollbars being a different size. Additionally I'm also doing Fit to Height and would need to get the Height of the horizontal scrollbar when it would be visible (I'm assuming that the answer to getting the width of the vertical scrollbar would make getting the height of the horizontal scrollbar obvious).
You can use SystemParameters.ScrollWidth.
Using ViewableHeight and ViewableWidth instead of ActualHeight and ActualWidth in my scaling calculations along with setting the scroll bars Visibility to Visible instead of Auto works. However I'll accept another answer that allows the scroll bars to be set to Auto instead.
Edit:
OK, I've now got the scroll bars set to Visible. Then I do my calculation with the ViewableHeight and ViewableWidth. Then I set the scroll bars back to Auto. This seems to work even if it's not all that elegant.