Costom ScrollViewer Wpf
I have made a slider that looks like the image below but I want to know if it’s possible to make the exact same thing but vertical and a ScrollViewer instead of a slider. I have tried a lot but not succeeded. Need it for a Listbox. I like that design a lot
6 Replies
Hey!
U can try using
Orientation="Vertical"
@Martina NordkvistAlright but that does not work.
Can u send me you'r part from .xaml code?
One moment, i will post code in 5 min
Done
- First, you need to create a Grid with two columns: one for the
ScrollViewer
containing the ListBox
, and one to display the Slider
.
- The horizontal ScrollBar
should be disabled since we don’t need it, and the vertical ScrollBar
should be hidden.
- You'll set it so that when the MainWindow
is loaded, the Slider
's maximum value is set to match the scrollable height of the ScrollViewer
.
Here is my xaml code for u
In the backend code (
xaml.cs
), make sure to have the following:
- At the top of MainWindow
, add the Loaded
event to set the slider’s maximum value based on the scrollable content.
- Also, include an event called VerticalSlider_ValueChanged
to sync the slider’s current position with the scrolling position.
@Martina Nordkvistcan i call you and show you?