I would like to allow click and drag scrolling using a ScrollViewer (i.e. click anywhere in the ScrollViewer and drag up or down, and it will scroll accordingly)
I have a StackPanel nested inside a ScrollViewer and I already have the scrolling working. I believe I saw that answer somewhere, but I can’t seem to find it anymore.
This has to be done using code only.
Look at this code from Matt Hamilton:
}
There are some quirks here. I noticed that the ScrollViewer was actually being loaded, unloaded and loaded again when the content was shown.
That meant that I couldn’t just hook up the events in the
IsEnabledChangedmethod and unhook them in thetarget_Unloadedevent handler, because they were being unhooked immediately. Instead, I’ve had to hook them up in a handler for the Loaded event, which in turn never gets unhooked.That means that there’s something of a “memory leak” in there, but it’s one I’m prepared to live with.