benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.73k stars 145 forks source link

ScrollViewer mouse wheel not working #50

Closed dbruning closed 4 years ago

dbruning commented 4 years ago

If you had a docs page called something like "Tips & tricks" or "Gotcha's", you could add this issue that I came across. I'm not sure why it used to work (before using Adonis styles) - probably because something used to have a background but now doesn't.

Symptom: Scrollviewer doesn't scroll with mousewheel after applying Adonis styles Possible cause: If you have a control inside a scrollviewer, and the control has a PreviewMouseDown event handler, you may need to add some code to the scrollviewer. See this Stack Overflow answer for details.

(or - feel free to close this issue, at least someone searching for it might find the answer here.)

benruehl commented 4 years ago

Thanks for giving knowledge to others. Currently, I am not quite sure what this is about though.

So you seem to have a ScrollViewer with a ListView inside, I guess. At least thats the setup in the StackOverflow thread you mentioned.

<ScrollViewer>
    <ListView/>
</ScrollViewer>

And the issue is that the ScrollViewer does not move its scroll bars when scrolling with the mouse wheel.

But if I create a new WPF project without any dependencies and put some items into the ListView it has this issue already. It scrolls only when dragging the thumb or scrolling directly over the scroll bar. Doesn't seem to have anything to do with AdonisUI. Did I get something wrong here?

Setting a background brush does not seem to change anything as well. When using AdonisUI the outer ScrollViewer even has Background="Transparent" which is specified in the default ScrollViewer style.

As far as I know, it is the default behavior of ScrollViewers to handle scroll events even if there is nothing to scroll. This is also pointed out in this blog post. And some controls like ListViews, ListBoxes, TreeViews, etc. make use of internal ScrollViewers that behave this way as well.

Again, please correct me in case I get this all wrong. But I don't see how this is related to AdonisUI. Do you have some XAML code that behaves differently when AdonisUI is included?

dbruning commented 4 years ago

My app didn't actually have a listview inside a scrollviewer. It had something far more complex, involving:

I just tried to distill it into a reproducable github repo, but failed to recreate the problem. I'm 100% sure I had to add that PreviewMouseWheel event handler & code in my app after adding Adonis, but I can't create a simple repro to share. Sorry! Maybe close this issue & if someone else hits my super edge case, they'll find this fix and maybe have more insight into the repro.

benruehl commented 4 years ago

Ok, I see its complicated. Thanks anyway, maybe it will be useful to someone in the future.