Home Forums WPF controls Xceed DataGrid for WPF Styling the TableView Scroll Bar

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25076 |

    Hi there,

    I’m finding it difficult to find a hook for styling the Datagrid’s Scrollbars in the Table View.
    I’m probably missing something that’s incredibally obvious – could somebody point me in the right direction?

    Many thanks,

    — Scott

    Imported from legacy forums. Posted by Scott (had 610 views)

    User (Old forums)
    Member
    Post count: 23064

    An easy way to style the scrollbars would be to set an implicit style at the DataGrid level, for example :

    <code>

    <xcdg:DataGridControl ItemsSource=”{Binding Source={StaticResource rssFeed}}”
    TextElement.FontSize=”24″>

    <xcdg:DataGridControl.Resources>

    <Style TargetType=”ScrollBar”>

    <Setter Property=”Background”
    Value=”Red”/>

    </Style>

    </xcdg:DataGridControl.Resources>

    </code>

    Remember that you can also set a new template at this level if you wish to provide your own.

    Imported from legacy forums. Posted by Matt (had 2471 views)

    User (Old forums)
    Member
    Post count: 23064

    Matt,

    That was great but how should we be doing the same if we intend to go the C# way. I am talking about being able to set the scrollbar styling dynamically.

    I tried this.

    Style

    style = new Style(typeof(DataGridScrollViewer));

    Setter setter = new Setter(DataGridScrollViewer.BackgroundProperty, System.Windows.Media.Brushes.Red);

    style.Setters.Add(setter);

    dataGrid.Resources.Add(style,

    typeof(DataGridScrollViewer));

    I know that I shouldn’t be targetting DataGridScrollViewer. So what is the component I should be targetting. I couldn’t find ScrollBar.

    Any help is greatly appreciated.

    -Prudhvi

    Imported from legacy forums. Posted by prudhvi (had 535 views)

    User (Old forums)
    Member
    Post count: 23064

    You are missing a using statement for the scrollbar class:

    using System.Windows.Controls.Primitives;

     

    Imported from legacy forums. Posted by Matt (had 993 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.