-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Description
When assigning a DataGrid column's HeaderTemplate or HeaderStyle with {DynamicResource ...}, the header is not displayed/styled.
<DataGrid x:Name="msDataGrid2" Grid.Column="1" Grid.Row="1" ItemsSource="{Binding Orders}" AutoGenerateColumns="False">
<DataGrid.Columns>
<!--DynamicResource-->
<DataGridTextColumn Binding="{Binding OrderID}" Header="Order ID" HeaderStyle="{ DynamicResource headerStyle}"/>
<DataGridTextColumn Binding="{Binding CustomerID}" HeaderTemplate="{DynamicResource headerTemplate}"/>
</DataGrid.Columns>
</DataGrid>
Note:
The same templates/styles work correctly when referenced with {StaticResource ...}.
<DataGrid x:Name="msDataGrid1" Grid.Row="1" Grid.Column="0" ItemsSource="{Binding Orders}" AutoGenerateColumns="False">
<DataGrid.Columns>
<!--StaticResource-->
<DataGridTextColumn Binding="{Binding OrderID}" Header="Order ID" HeaderStyle="{ StaticResource headerStyle}"/>
<DataGridTextColumn Binding="{Binding CustomerID}" HeaderTemplate="{StaticResource headerTemplate}"/>
</DataGrid.Columns>
</DataGrid>
Please refer the Screenshot for your reference
Reproduction Steps
- Run the sample and observe the headers of the two DataGrid columns.
- The column that uses StaticResource displays the expected header style and template, whereas the column that uses DynamicResource appears unstyled and shows a blank header.
Expected behavior
The DynamicResource-referenced column header should rendered/styled correctly.
Actual behavior
The DynamicResource-referenced column header is not rendered/styled correctly.
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
I have attached the sample for your reference.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels