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

Fix DataGrid GroupRow styles #370

Merged
merged 1 commit into from
Dec 29, 2024
Merged

Conversation

sn4k3
Copy link
Contributor

@sn4k3 sn4k3 commented Dec 28, 2024

This PR aim to fix the DataGrid GroupRow styles as explaned in #363

(Help wanted) It still has some annoyances I can't get to work:

  • When click on expander arrow it will change arrow state but does not expand nor hide
  • When click on header it will expand and hide but not change arrow state
  • Missing Suki animations for expander
SukiUI.Demo_2024-12-28_17-59-15.mp4

As we don't include DataGrid theme from Avalonia there are many things missing, as for example, we can't aim DataGridRow type for inline styling of row because it does not exists as ControlTheme: <ControlTheme x:Key="{x:Type DataGridRow}" TargetType="DataGridRow">.
A better approach would be include default DataGrid theme and override the key parts on Suki, or copy over from Avalonia and change every element to match Suki.
The Fluent theme of DataGrid already include many ResourceDictionary that we can tune, however some key parts are still missing.

Sample effect of lacking stock ControlThemes:
image

@kikipoulet kikipoulet merged commit 0f1fd7d into kikipoulet:main Dec 29, 2024
@kikipoulet
Copy link
Owner

I'm not in a hurry to take a look at this as I'm on vacation but we will definitely try to support DataGrid correctly.

You seem to have a deep usage of DataGrid control, I'm really wondering by curiosity what is your use-case and what you're trying to do with this control.

@kikipoulet
Copy link
Owner

I did a first rough fix. Modifications will be needed to polish style at least

@sn4k3 sn4k3 deleted the datagrid-fixes branch December 29, 2024 23:27
@sn4k3
Copy link
Contributor Author

sn4k3 commented Dec 29, 2024

You seem to have a deep usage of DataGrid control, I'm really wondering by curiosity what is your use-case and what you're trying to do with this control.

Nothing fancy... You can see my grid on #363, I have a ping collection and I like to set row background to Red when a ping fails otherwise stays normal, this is impossible due lack of styles (Also not possible with code behind). I try to set colors per item status which also impossible due the lack of ControlTheme as shown on image.
Using groups to stack per user defined groups.

As the theme is missing some key components from base makes it poor for customization.

@kikipoulet
Copy link
Owner

Well, isn't it about making a nice fancy datagrid design ? If it's an open-source project I would be curious to look at the repo.

I will look for a row color solution, don't forget to try the last quick fix I did to see if it's what you wanted

@sn4k3
Copy link
Contributor Author

sn4k3 commented Dec 30, 2024

It will be open-source but normally I only push repo online on first release (Which is a bit far given my concept).
But if you wish I can send you a source copy.
It's easy to replicated by this code:

<DataGrid.Styles>
    <Style Selector="DataGridRow">
        <Setter Property="Background" Value="DarkRed" />
    </Style>
</DataGrid.Styles>

To change background based on item status we can use:

<DataGrid.RowTheme>
    <ControlTheme
        x:DataType="network:PingableService"
        BasedOn="{StaticResource {x:Type DataGridRow}}"
        TargetType="DataGridRow">
        <Setter Property="Background" Value="{Binding WasLastPingSucceeded, Converter={StaticResource BoolErrorGridRowBackground}}" />
    </ControlTheme>
</DataGrid.RowTheme>

However, the last will not compile due lack of DataGridRow ControlTheme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants