-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
Iterating through the resources of any Fluent theme will throw this exception
ArgumentException: 'DataGridCheckBoxColumn' type must derive from FrameworkElement or FrameworkContentElement.
Which leads back to these styles:
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml
Line 62 in 94751f5
| <Style x:Key="DefaultDataGridCheckBoxColumnCellStyle" TargetType="{x:Type DataGridColumn}" /> |
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml
Lines 505 to 507 in 94751f5
| <Style TargetType="{x:Type DataGridTextColumn}"> | |
| <Setter Property="EditingElementStyle" Value="{StaticResource TextBoxStyle}" /> | |
| </Style> |
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml
Lines 792 to 795 in 94751f5
| <Style TargetType="{x:Type DataGridCheckBoxColumn}"> | |
| <Setter Property="ElementStyle" Value="{StaticResource DataGridCheckBoxElementDefaultStyle}" /> | |
| <Setter Property="EditingElementStyle" Value="{StaticResource DataGridCheckBoxEditingElementDefaultStyle}" /> | |
| </Style> |
This is because DataGridColumn and derived types inherit from DependencyObject not FrameworkElement or FrameworkContentElement and therefore cannot be styled.
Reproduction Steps
Expected behavior
Iterating through the framework's resources should not cause an exception.
DataGridColumn, DataGridTextColumn and DataGridCheckBoxColumn should not have any styles.
Actual behavior
ArgumentException: 'DataGridColumn' type must derive from FrameworkElement or FrameworkContentElement.
ArgumentException: 'DataGridTextColumn' type must derive from FrameworkElement or FrameworkContentElement.
ArgumentException: 'DataGridCheckBoxColumn' type must derive from FrameworkElement or FrameworkContentElement.
Regression?
No response
Known Workarounds
No response
Impact
Impacts all Fluent themes.
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.HC.xaml
Line 1482 in 94751f5
| <Style x:Key="DefaultDataGridCheckBoxColumnCellStyle" TargetType="{x:Type DataGridColumn}" /> |
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Dark.xaml
Line 1510 in 94751f5
| <Style x:Key="DefaultDataGridCheckBoxColumnCellStyle" TargetType="{x:Type DataGridColumn}" /> |
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Light.xaml
Line 1505 in 94751f5
| <Style x:Key="DefaultDataGridCheckBoxColumnCellStyle" TargetType="{x:Type DataGridColumn}" /> |
Configuration
.NET 9 Preview 7
Microsoft Windows 11 Pro 10.0.22631
x64
Other information
Looks this is also present in WPF UI too https://github.com/lepoco/wpfui/blob/4ac96867797267d566b82fbbfcab0c867353afaa/src/Wpf.Ui/Controls/DataGrid/DataGrid.xaml#L64