The WPF WebBrowser
control actually wraps the native WebBrowser ActiveX control inside it. That doesn't really change the answer but it's good to know.
As Reza Aghaei already commented, the scrollbars are not WPF controls and cannot be modified like other scrollbars in WPF applications. However, I don't think that you can change the width of the IE scrollbars using CSS, because the styling is only limited to coloring:
scrollbar-base-color: #C0C0C0;
scrollbar-base-color: #C0C0C0;
scrollbar-3dlight-color: #C0C0C0;
scrollbar-highlight-color: #C0C0C0;
/* etc */
Two possibilities come to mind. Either you use one of the jQuery scrollbar libraries that let you customize the scrollbar, or you use the native WPF ScrollBar
instead.
Using jQuery scrollbars would force you to inject javascript on each page the user visits and it might get really dirty when the website already has custom jQuery scrollbars in use. This could be worth looking into, but I doubt it would work well enough in practice.
Here's what I would try
- Hide the scrollbar by giving
overflow:hidden
style to the body of each page. You could also host the Windows Forms WebBrowser
inside the WindowsFormsHost
control so you would get access to the ScrollBarsEnabled
property (which unfortunately isn't available on the WPF control).
- Add the WPF
ScrollBar
next to your WebBrowser
control and style it the way you want to. This could actually be a UserControl
to ensure future reusability.
- Set the WPF
ScrollBar
's maximum value to the ScrollHeight of the HTML page.
- Subscribe to the scroll event of WPF
ScrollBar
. Send the scroll events to the HTML page. You would also need to do it the other way to keep the WPF ScrollBar
synced with scroll that happens using touch, mouse wheel or keyboard buttons.
I'm not on a computer right now so can't help with the numbers 3 and 4 but it should certainly be possible. Again you could run into pages that use some custom scrolling (jQuery) but hopefully this gets you started.