J'ai un problème bizarre avec le DataGrid
dans WPFToolkit (.NET 3.5) et la version intégrée dans .NET 4.0:Explicit DataGrid CellStyle Setter est remplacé par un cellstyle implicite dans le même contexte?
Lors de la création d'un calée DataGrid
avec un compositeur de style explicite pour CellStyle
à un autre style clé il fonctionne comme suspecté. Mais lorsque vous créez également un style sans clé pour DataGridCell
, il remplace le CellStyle
-setter explicite dans le style DataGrid
. Cela semble faux. Est-ce par conception ou est-ce un bug?
<Window.Resources>
<Style TargetType="DataGridCell">
<Setter Property="Background" Value="Blue" />
</Style>
<Style x:Key="CellStyle1" TargetType="DataGridCell">
<Setter Property="Background" Value="Green" />
</Style>
<Style TargetType="DataGrid">
<Setter Property="Background" Value="Yellow" />
<Setter Property="CellStyle" Value="{StaticResource CellStyle1}" />
</Style>
<XmlDataProvider x:Key="xmldata" XPath="data/*">
<x:XData>
<data xmlns="">
<item1 />
<item2 />
<item3 />
</data>
</x:XData>
</XmlDataProvider>
</Window.Resources>
<Grid>
<DataGrid ItemsSource="{Binding Source={StaticResource xmldata}}" />
</Grid>