wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Fluent Themes contain invalid DataGridColumn styles

Open MitchRazga opened this issue 1 year ago • 2 comments

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: https://github.com/dotnet/wpf/blob/94751f56a45603960704642bdbc245a78e725644/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml#L62 https://github.com/dotnet/wpf/blob/94751f56a45603960704642bdbc245a78e725644/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml#L505-L507 https://github.com/dotnet/wpf/blob/94751f56a45603960704642bdbc245a78e725644/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml#L792-L795

This is because DataGridColumn and derived types inherit from DependencyObject not FrameworkElement or FrameworkContentElement and therefore cannot be styled.

Reproduction Steps

TestResources.zip

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. https://github.com/dotnet/wpf/blob/94751f56a45603960704642bdbc245a78e725644/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.HC.xaml#L1482 https://github.com/dotnet/wpf/blob/94751f56a45603960704642bdbc245a78e725644/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Dark.xaml#L1510 https://github.com/dotnet/wpf/blob/94751f56a45603960704642bdbc245a78e725644/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Themes/Fluent.Light.xaml#L1505

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

MitchRazga avatar Sep 10 '24 13:09 MitchRazga

I would suggest the issue is kept open until a PR merged.

miloush avatar Sep 10 '24 14:09 miloush

I would suggest the issue is kept open until a PR merged.

Whoops. Didn't realize that merging in the fork would close it here

MitchRazga avatar Sep 10 '24 14:09 MitchRazga