Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid Scrollbar column header not stylized #3518

Open
andrewwong0893 opened this issue Apr 7, 2024 · 1 comment
Open

DataGrid Scrollbar column header not stylized #3518

andrewwong0893 opened this issue Apr 7, 2024 · 1 comment
Labels
Waiting on feedback Additional information is needed. Stale items with this label may be closed.

Comments

@andrewwong0893
Copy link

Bug explanation

I'm not sure whether this is a bug or not but I have a DataGrid where I have formatted the column headers to a generic style that is consistent:

<Style TargetType="DataGridColumnHeader">
    <Setter Property="Background" Value="{StaticResource PrimaryColor}" />
    <Setter Property="Foreground" Value="White" />
    <Setter Property="Padding" Value="12,15" />
</Style>

When I load a bunch of data to my grid, a ScrollViewer will automatically appear. However, the column where the scrollbar is placed is not stylized.

image

<DataGrid
    x:Name="_ComponentGrid"
    Grid.Row="2"
    ItemsSource="{Binding ComponentTableModels}"
    ScrollViewer.CanContentScroll="True"
    SelectionMode="Extended"
    SelectionUnit="FullRow"
    VerticalScrollBarVisibility="Auto">
    <DataGrid.Columns>
      ...
   </DataGrid.Columns>
</DataGrid>

Is there a way for me to bring the style over to the scroll bar column?

Version

5.0.0

@andrewwong0893 andrewwong0893 added bug evaluation required Items is pending review or evaluation by the team labels Apr 7, 2024
@nicolaihenriksen
Copy link
Contributor

nicolaihenriksen commented Jun 14, 2024

@andrewwong0893 This is not particularly an issue with the MaterialDesignInXAML library, the same behavior can be observed with the default style of the DataGrid. The "scroll bar column" is actually not a column at all, it is an empty area in the ScrollViewer template. If you had both a horizontal and a vertical scrollbar, you would also have a small square in the bottom right hand corner with a similar empty area.

I believe your best option would be to write a custom template for the DataGrid. The current MDIX template seems to be very much based on the default WPF template for the DataGrid. You should be able to create a template where the ScrollViewer only encapsulates the rows, and thereby avoid the "scroll bar column". However, this comes at the price that the ScrollViewer (width) will eat some of the available real-estate of the right-most column, so there are caveats to this approach.

@nicolaihenriksen nicolaihenriksen added Waiting on feedback Additional information is needed. Stale items with this label may be closed. and removed bug evaluation required Items is pending review or evaluation by the team labels Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting on feedback Additional information is needed. Stale items with this label may be closed.
Projects
None yet
Development

No branches or pull requests

2 participants