Skip to content

Implemented shorthand syntax for ColumnDefinitions and RowDefinitions#10866

Merged
himgoyalmicro merged 6 commits into
dotnet:mainfrom
himgoyalmicro:xaml-grid-shorthand
May 21, 2025
Merged

Implemented shorthand syntax for ColumnDefinitions and RowDefinitions#10866
himgoyalmicro merged 6 commits into
dotnet:mainfrom
himgoyalmicro:xaml-grid-shorthand

Conversation

@himgoyalmicro
Copy link
Copy Markdown
Contributor

@himgoyalmicro himgoyalmicro commented May 21, 2025

Implements #9802

Description

It will simplify the definition syntax of RowDefinitions and ColumnDefinitions by:

  • Allowing rows and columns within a Grid to be defined by a collection that is delimited by comma and space
  • Creating a Typeconvertor for ColumnDefinitionCollection and RowDefinitionCollection so they can process String as its input.

Decoupled RowDefinitionCollection and ColumnDefinitionCollection from the owner grid to ensure VS Hot Reload functionality remains intact.

Customer Impact

This feature will make Grid markup less verbose, allowing developers to create grids with simpler syntax.

Regression

N/A

Testing

Local build pass

Risk

Low

PS earlier this was being tracked by #10317 but using this PR now to make the commit history cleaner.

Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings May 21, 2025 06:08
@himgoyalmicro himgoyalmicro requested a review from a team as a code owner May 21, 2025 06:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a shorthand syntax for defining grid rows and columns by introducing type converters that allow string conversion to RowDefinitionCollection and ColumnDefinitionCollection, and updates grid properties accordingly.

  • Added ColumnDefinitionCollectionConverter and RowDefinitionCollectionConverter classes.
  • Modified Grid, RowDefinitionCollection, and ColumnDefinitionCollection to support owner management and simplified property setters.
  • Adjusted API compatibility baselines to reflect the attribute changes.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
PresentationFramework.cs Added converter stubs for collection type conversion.
WpfGeneratedKnownProperties.cs Updated delegates and TypeConverterType assignments for grid properties.
RowDefinitionCollectionConverter.cs and ColumnDefinitionCollectionConverter.cs Implemented string conversion for row/column definition collections.
RowDefinition.cs and ColumnDefinition.cs Updated constructors and owner setters to decouple from the grid.
Grid.cs Added setters for ColumnDefinitions/RowDefinitions and incorporated owner management.
PresentationFramework.csproj Included new converter files.
ApiCompat Baseline Reflects modifications in attributes on Grid properties.
Comments suppressed due to low confidence (1)

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/Grid.cs:283

  • [nitpick] The exception message uses inconsistent naming (using 'nameof(value)' here versus 'nameof(Grid)' elsewhere) in the owner assignment logic; standardize the parameter names for clarity.
throw new ArgumentException(SR.Format(SR.GridCollection_InOtherCollection, nameof(value), nameof(ColumnDefinitionCollection)));

@dotnet-policy-service dotnet-policy-service Bot added the PR metadata: Label to tag PRs, to facilitate with triage label May 21, 2025
Copy link
Copy Markdown
Member

@dipeshmsft dipeshmsft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 166 lines in your changes missing coverage. Please review.

Project coverage is 13.41294%. Comparing base (ba62855) to head (c031d5c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10866         +/-   ##
===================================================
- Coverage   13.42191%   13.41294%   -0.00897%     
===================================================
  Files           3317        3319          +2     
  Lines         664749      664895        +146     
  Branches       74643       74675         +32     
===================================================
- Hits           89222       89182         -40     
- Misses        572982      573165        +183     
- Partials        2545        2548          +3     
Flag Coverage Δ
Debug 13.41294% <0.00000%> (-0.00897%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@himgoyalmicro himgoyalmicro merged commit 3dc2b97 into dotnet:main May 21, 2025
8 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants