dotnet / dotnet/wpf

Setting the ColumnDefinitions/RowDefinitions properties of a Grid panel is only possible if the value is string as the ColumnDefinitionCollection/RowDefinitionCollection types do not have a public constructor

Open
#11,273 0 comments 1 reaction 1 assignee Claimed by @himgoyalmicro View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

With the **.NET 10** version, a new functionality to simplify the definition of **ColumnDefinition** and **RowDefinition** instances for the **Grid** panel was introduced. The changes come from this [issue](https://github.com/dotnet/wpf/issues/9802?utm_source).

Now, the **ColumnDefinitions**/**RowDefinitions** properties have a **set** method introduced with this change. However, the **ColumnDefinitionCollection**/**RowDefinitionCollection** types cannot be instantiated as they do not have a public constructor. Hence, the only possible approach is to use **string** as a value or create instances of **ColumnDefinition**/**RowDefinition** to be added one by one via the **Add** method..

### Reproduction Steps

1. Create a .NET 10 WPF application
2. Add the following code
`Grid grid = new Grid();
grid.ColumnDefinitions = new ColumnDefinitionCollection();`

### Expected behavior

To not be limited to using only a value of the type of **string** to set the **ColumnDefinitionCollection**/**RowDefinitionCollection** properties.

### Actual behavior

The **ColumnDefinitionCollection**/**RowDefinitionCollection** do not have a public constructor, hence they cannot be instantiated, and this forces the use of a value of the type of **string**, or create instances of **ColumnDefinition**/**RowDefinition** to be added one by one via the **Add** method.

### Regression?

_No response_

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

- WPF application with .NET 10 version

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.