0
votes

first, what I am trying to do: I have a WPF datagrid with one column and x rows. I have a Style-Trigger that Sets the ScrollViewer.VerticalScrollBarVisibility to Visible as soon as IsMouseOver is True. Its working as expected, but the Problem is, the Column will be resized by the appereance of the scrollbar (scrollbar width 5 px). So i decided to set a padding to my grid that changes from 5 to 0 when the scrollbar is shown.

Its working all well, but if my Rows dont exceed the border of the datagrid, a grey disabled background is shown. I could set the ScrollViewer.VerticalScrollBarVisibility to Auto instead, then the background wont show up if there is enough space in my datagrid, but then the padding resizes the column (because there is no 5px scrollbar that is shown)

So i decided to stick with the Visible- instead of the Auto setting and try to make this disabled scrollbar background transparent. is this possible or is it posible to solve this problem with another workaround?

1
I googled "WPF Transparent scrollbar" and found this guide which overlaps the scrollbars over the content itself and makes them transparent. It sounds like it might do the trick for you. It uses a Style Trigger to apply this <Setter Property="Opacity" Value="0.4" />. The only problem is the entire scrollbar, not just the background / scroll tracker, is transparent.sab669
Thats not really what i want as you guessed already, but in the meantime i got a solution. see my answer belowxb1xbv1
Yea I was just hoping maybe it'd help you figure out something. BUt I see you did find a solution, so, cool.sab669

1 Answers

1
votes

I found a solution. Quick and Dirty:

  1. Get Style from this Project: http://www.codeproject.com/Articles/41787/Creating-a-Blend-like-Scrollbar
  2. Copy Style Information from Scrollbar.xml to your desired project
  3. Give the Style-Tag a Name (so not every scrollbar will be styled that way!) with x:Key="NAME"
  4. Go to your DataGrid and post this code between the datagrid-opening and closing tags:

That's it! You can Style your Scrollbar as you like and it will be changed in your datagrid (and just there!)