Skip to content

DataGrid style cleanup#3033

Merged
Keboo merged 7 commits intoMaterialDesignInXAML:masterfrom
nicolaihenriksen:datagridStyleCleanup
Jan 19, 2023
Merged

DataGrid style cleanup#3033
Keboo merged 7 commits intoMaterialDesignInXAML:masterfrom
nicolaihenriksen:datagridStyleCleanup

Conversation

@nicolaihenriksen
Copy link
Copy Markdown
Contributor

@nicolaihenriksen nicolaihenriksen commented Jan 8, 2023

Fixes #3009

This PR introduces a new attached property, DataGridAssist.ApplyMaterialDesignColumnStyles, which works for both auto-generated and explicitly-defined columns. It still allows overriding of the style in XAML where needed. It works by inspecting the ElementStyle/EditingElementStyle of the columns in the DataGrid and applies the MDIX styles if the values have not been explicitly overridden.

This could possibly be interpreted as a "visual breaking change" as some columns that previously were not automatically styled, now are automatically styled (ComboBox).

It also introduces new attached properties, DataGridAssist.AutoGeneratedComboBoxStyle and DataGridAssist.AutoGeneratedEditingComboBoxStyle, similar to the existing ones for "text" and "checkbox" columns. This gives the user an ability to override the style for auto-generated ComboBox columns. These properties (along with the existing ones) are no longer needed if the intention is to simply override with the default MDIX styles, but could be useful if you have a completely custom style you would like to apply.

@nicolaihenriksen
Copy link
Copy Markdown
Contributor Author

@Keboo Could you have a look at this PR when you have time? I would like to hear if you see any pitfalls with this approach.

I have tried to keep it relatively simple and flexible without introducing breaking changes. I think I was successful in doing so, but I would like you to sanity check it 😄

@nicolaihenriksen nicolaihenriksen requested a review from Keboo January 8, 2023 15:20
@nicolaihenriksen
Copy link
Copy Markdown
Contributor Author

nicolaihenriksen commented Jan 8, 2023

UPDATE: Nevermind, I confused myself. These are of course only uploaded to the particular build as artifacts.


@Keboo And why are PRs now uploading artifacts and whatnot? Was that part of your pipeline changes? Thought it was only the "Release" PR that needed this.

image

nicolaihenriksen and others added 7 commits January 17, 2023 10:00
Similar to text and checkbox columns, the auto-generated style can now be set using an attached property.
…perty

The attached property, when set, inspects all columns of the data grid and applies MDIX styles if the default style has not been overridden. This works both for auto-generated and explicitly-defined columns.
The assist class now uses the attached properties associated with the corresponding DataGrid. Introduced a ColumnUpdater type and a private DP in order to have a reference to the DataGrid in the Columns_CollectionChanged() callback and to do proper housekeeping/cleanup to avoid memory leaks.
Co-authored-by: Kevin B <Keboo@users.noreply.github.com>
Removing the ColumnUpdater in place of a local function which captures the variable nicely. This removes the need for the ColumnUpdater type entirely, and removes the associated attached property.
@nicolaihenriksen
Copy link
Copy Markdown
Contributor Author

@Keboo Didn't even think of using a local function to capture the dataGrid variable. MUCH nicer! Cleaned it up, rebased and force pushed.

@Keboo Keboo modified the milestones: 5.0.0, 4.8.0 Jan 19, 2023
@Keboo Keboo merged commit 0dd2438 into MaterialDesignInXAML:master Jan 19, 2023
@nicolaihenriksen nicolaihenriksen deleted the datagridStyleCleanup branch January 21, 2023 08:31
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.

Is it possible to embed ElementStyle & EditingElementStyle in Style?

2 participants