WPF ツールキットがインストールされ参照されている vS 2008。Window1.xaml に次の行を追加しました。
xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"
グリッドのスタイルを設定しようとするまで、実行され、グリッドにデータが表示されます。テキストを中央揃えにするスタイルを適用しようとすると、エラーが発生します。エラーは App.xaml を参照しており、次のとおりです。
タイプ参照は、'DataGridCell' という名前のパブリック タイプを見つけることができません。行 9 位置 75。
私のApp.xaml
<Application x:Class="DataGridStyles.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
<Style x:Key="CenterCellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</Application.Resources>
</Application>