次のようなコンバーターを追加します。
namespace System.Converters
{
//Converter for cell animation
public class flashConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string cellvalue = value.ToString();
return cellvalue = ("place the condition here");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return false;
}
}
MainWindow.xaml.csに名前空間を追加します
xmlns:loc="clr-namespace:YourProjectName.Converters"
リソースに以下を追加します。
<DataGrid.Resources>
<loc:flashConverter x:Key="SomeConverter"></loc:flashConverter>
</DataGrid.Resources>
DatagridTextColumnに、次を追加します。
<DataGridTextColumn Header="yourDatagridHeader" IsReadOnly="True" Binding="{Binding Path=yourDatagridHeader}">
<DataGridTextColumn.ElementStyle>
<!--Style to implement the datagrid cell animation for yourDatagridcell-->
<Style TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding yourDatagridHeader}" Value="Give your condition here">
<!-#E6F85050 is the hexadecimal value for RED-->
<Setter Property="Background" Value="#E6F85050"/>
</DataTrigger>
<DataTrigger Binding="{Binding yourDatagridHeader}" Value="Give your condition here">
<Setter Property="Background" Value="give the hexadecimal value for transparent here "/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
お役に立てれば !