Skip to content

Commit 718d1b9

Browse files
Copilotgewarren
andcommitted
Add WPF MC3063 breaking change documentation for empty Grid definitions
Co-authored-by: gewarren <[email protected]>
1 parent 3bca537 commit 718d1b9

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,5 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
118118

119119
| Title | Type of change | Introduced version |
120120
|-------|---------------------------------------|--------------------|
121+
| [WPF throws MC3063 error for empty ColumnDefinitions or RowDefinitions](wpf/10.0/empty-grid-definitions.md) | Source incompatible | Preview 5 |
121122
| [Incorrect usage of DynamicResource causes application crash](wpf/10.0/dynamicresource-crash.md) | Source incompatible/behavioral change | Preview 4 |

docs/core/compatibility/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ items:
130130
href: windows-forms/10.0/statusstrip-renderer.md
131131
- name: WPF
132132
items:
133+
- name: WPF throws MC3063 error for empty ColumnDefinitions or RowDefinitions
134+
href: wpf/10.0/empty-grid-definitions.md
133135
- name: Incorrect usage of DynamicResource causes application crash
134136
href: wpf/10.0/dynamicresource-crash.md
135137
- name: .NET 9
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
title: "Breaking change - WPF throws MC3063 error for empty ColumnDefinitions or RowDefinitions"
3+
description: "Learn about the breaking change in .NET 10 where empty Grid.ColumnDefinitions or Grid.RowDefinitions declarations now cause MC3063 compilation errors."
4+
ms.date: 01/27/2025
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/dotnet/docs/issues/47743
7+
---
8+
9+
# WPF throws MC3063 error for empty ColumnDefinitions or RowDefinitions
10+
11+
Starting with .NET 10 Preview 5, WPF applications fail to build if `<Grid.ColumnDefinitions>` or `<Grid.RowDefinitions>` are declared but left empty in XAML. This results in error **MC3063**, indicating that the property doesn't have a value.
12+
13+
## Version introduced
14+
15+
.NET 10 Preview 5
16+
17+
## Previous behavior
18+
19+
WPF applications with empty `<Grid.ColumnDefinitions>` or `<Grid.RowDefinitions>` compiled successfully, even though the layout definitions were incomplete. WPF would default to a single row and column, placing all child elements in that single cell unless otherwise specified.
20+
21+
Example that previously compiled:
22+
23+
```xml
24+
<Grid>
25+
<Grid.ColumnDefinitions>
26+
</Grid.ColumnDefinitions>
27+
<Grid.RowDefinitions>
28+
</Grid.RowDefinitions>
29+
<TextBlock Text="Hello World" />
30+
</Grid>
31+
```
32+
33+
## New behavior
34+
35+
The same code now fails to compile with the following error:
36+
37+
```output
38+
error MC3063: Property 'ColumnDefinitions' does not have a value.
39+
error MC3063: Property 'RowDefinitions' does not have a value.
40+
```
41+
42+
This occurs when `<Grid.ColumnDefinitions>` or `<Grid.RowDefinitions>` elements are declared but contain no child `<ColumnDefinition />` or `<RowDefinition />` elements.
43+
44+
## Type of breaking change
45+
46+
This is a [source-incompatible](../../categories.md#source-compatibility) change.
47+
48+
## Reason for change
49+
50+
This change is a direct consequence of implementing Grid XAML Shorthand Syntax support. The enhancement improves XAML parsing by being more strict about property declarations that don't contain meaningful content.
51+
52+
## Recommended action
53+
54+
Choose one of the following approaches to resolve the compilation error:
55+
56+
### Option 1: Remove empty declarations
57+
58+
Remove the empty `<Grid.ColumnDefinitions>` and `<Grid.RowDefinitions>` elements entirely:
59+
60+
```xml
61+
<Grid>
62+
<TextBlock Text="Hello World" />
63+
</Grid>
64+
```
65+
66+
### Option 2: Add actual definitions
67+
68+
If you need specific column or row definitions, add the appropriate `<ColumnDefinition />` or `<RowDefinition />` elements:
69+
70+
```xml
71+
<Grid>
72+
<Grid.ColumnDefinitions>
73+
<ColumnDefinition />
74+
</Grid.ColumnDefinitions>
75+
<Grid.RowDefinitions>
76+
<RowDefinition />
77+
</Grid.RowDefinitions>
78+
<TextBlock Text="Hello World" />
79+
</Grid>
80+
```
81+
82+
## Affected APIs
83+
84+
None.

0 commit comments

Comments
 (0)