Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change DataGrid ScrollBar visibility on mouse over?

How can I toggle the visibility of a DataGrid scrollbar on the IsMouseOver property of DataGrid?

I want to make the scrollbar visible when the mouse hovers over the DataGrid and invisible when the mouse goes out of the DataGrid. A XAML example would be appreciated.

like image 629
Lucifer Avatar asked Feb 04 '12 10:02

Lucifer


1 Answers

I would apply a new style, something like this:

<Style x:Key="dataGridStyle" TargetType={x:Type DataGrid}>
   <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
   <Style.Triggers>
       <Trigger Property="IsMouseOver" Value="True">
           <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
       </Trigger>
   </Style.Triggers>
 </Style>
like image 123
roberther Avatar answered Sep 30 '22 07:09

roberther