The MinWidth defined in the style DataGridRowHeader in APP.xaml results in incorrect rendering and display effects
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
### Abnormal 1:
```
<Setter Property="MinWidth" Value="40" />
```
The MinWidth defined in the style DataGridRowHeader in **APP.xaml** causes incorrect rendering and display effects.

(If MinWidth is defined elsewhere for DataGridRowHeader, it is normal.)
### Abnormal 2:
```
<Setter Property="Height" Value="25"/>
<Style.Triggers >
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="#a2a2a0"/>
<Setter Property="Background" Value="#FFA500"/>
<Setter Property="BorderThickness" Value="0.5"/>
<Setter Property="FontWeight" Value="UltraBlack"/>
<Setter Property="Foreground" Value="Black"/>
</Trigger>
</Style.Triggers>
```
If this is defined in **MainWindow.xaml**

If this is defined in **APP.xaml**, only the first of the six cells will present a blue background

### Abnormal 3:
```
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="Background"
Value="#ccc" />
<Style.Triggers>
<Trigger Property="AlternationIndex"
Value="0">
<Setter Property="Background"
Value="#FFFFEF" />
</Trigger>
<Trigger Property="AlternationIndex"
Value="1">
<Setter Property="Background"
Value="#FFFFFF" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="#ffcc33" />
<!--<Setter Property="Foreground" Value="White"/>-->
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Foreground"
Value="Black" />
</Trigger>
</Style.Triggers>
```
Other similar errors include a background exception when defining the Trigger of the AlternationIndex, which is related to the display effect of the first cell in the first row

### Code
App.xaml
```
<Setter Property="VerticalAlignment"
Value="Center" />
<Setter Property="Background"
Value="#ccc" />
<Style.Triggers>
<Trigger Property="AlternationIndex"
Value="0">
<Setter Property="Background"
Value="#FFFFEF" />
</Trigger>
<Trigger Property="AlternationIndex"
Value="1">
<Setter Property="Background"
Value="#FFFFFF" />
</Trigger>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Background"
Value="#ffcc33" />
<!--<Setter Property="Foreground" Value="White"/>-->
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter Property="Foreground"
Value="Black" />
</Trigger>
</Style.Triggers>
```
MainWindow.xaml
```
```
MainWindow.xaml.cs
```
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WpfAppTest
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public List ICDFields { get; set; } = new List { };
public MainWindow()
{
ICDFields.Add(new DataItem("111"));
ICDFields.Add(new DataItem("222"));
ICDFields.Add(new DataItem("333"));
InitializeComponent();
//dgList.ItemsSource = ICDFields;
}
}
public class DataItem
{
[DisplayName("Name")]
[Browsable(true)]
public string Name { get; set; }
[DisplayName("Value")]
[Browsable(true)]
public string Value { get; set; } = "abcd";
public DataItem(string name)
{
Name=name;
}
}
}
```
### Reproduction Steps
1. Create net6.0-windows WpfApp
2. App. xaml defines DataGrid related error styles
3. MainWindow.xaml defines DataGrid
4. MainWindow.xaml.cs binding DataGrid data
5. Run
### Expected behavior
```
<Setter Property="MinWidth" Value="40" />
```
The MinWidth defined in the style DataGridRowHeader in **APP.xaml** causes incorrect rendering and display effects.

### Actual behavior
No exceptions were thrown, only the interface display was abnormal
### Regression?
unknown
### Known Workarounds
This type of style is not defined in APP.xaml
### Impact
unknown
### Configuration
Windows 11 x64 22H2 22621.2428
VS 2022
net6.0-windows SDK 6.0.318 x64
### Other information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.