asusralis
Topic Author
Posts: 108
Joined: 30 Jul 2018, 05:03

How to check if a scrollviewer's scrollbar is pressed or not?

27 Oct 2020, 00:57

I figured I'd try to see if the scrollbar is currently focused, but if this isn't how you'd do that I would need to try something else. It seems I can't get the scrollbar from the scrollviewer in Noesis. I found this topic for WPF, but none of the solutions worked for me, they all couldn't find the bar.
 
User avatar
sfernandez
Site Admin
Posts: 2056
Joined: 22 Dec 2011, 19:20

Re: How to check if a scrollviewer's scrollbar is pressed or not?

27 Oct 2020, 13:14

Can I ask what is the goal of detecting if ScrollBar is pressed? If you need to know when it is scrolling or being dragged there are events you can attach to in the ScrollViewer:
scrollViewer.AddHandler(ScrollBar.ScrollEvent, ...);
scrollViewer.AddHandler(Thumb.DragStartedEvent, ...);
scrollViewer.AddHandler(Thumb.DragDeltaEvent, ...);
scrollViewer.AddHandler(Thumb.DragCompletedEvent, ...);
About finding the bar, if you are using our NoesisTheme, the ScrollViewer template contains horizontal and vertical scroll bars named respectively as PART_HorizontalScrollBar and PART_VerticalScrollBar. Calling the following code should get you the vertical scroll bar:
ScrollBar sb = (ScrollBar)scrollviewer.Template.FindName("PART_VerticalScrollBar", scrollviewer);
Isn't that working for you? Are you using your own template for the ScrollViewer?
 
asusralis
Topic Author
Posts: 108
Joined: 30 Jul 2018, 05:03

Re: How to check if a scrollviewer's scrollbar is pressed or not?

28 Oct 2020, 04:36

I have a continuous loading of messages when the scrollviewer gets to a certain point at the top, but this can't happen if the bar is pressed. I can try to listen to these handlers and track if it's being dragged on my own, thanks.

Who is online

Users browsing this forum: Google [Bot] and 2 guests