DataGrid style cleanup#3033
Merged
Keboo merged 7 commits intoMaterialDesignInXAML:masterfrom Jan 19, 2023
Merged
Conversation
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 😄 |
Contributor
Author
|
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. |
Keboo
reviewed
Jan 10, 2023
a6e281a to
12df710
Compare
Keboo
reviewed
Jan 17, 2023
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.
2e66a92 to
6d60ec5
Compare
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
approved these changes
Jan 19, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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 theElementStyle/EditingElementStyleof the columns in theDataGridand 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.AutoGeneratedComboBoxStyleandDataGridAssist.AutoGeneratedEditingComboBoxStyle, similar to the existing ones for "text" and "checkbox" columns. This gives the user an ability to override the style for auto-generatedComboBoxcolumns. 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.