1、创建BgROW类
public class BgROW : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value.ToString()=="true")
{
return new SolidColorBrush(Color.FromRgb(46, 170, 231));
}
else
return new SolidColorBrush(Color.FromRgb(229, 73, 54));
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
2、在xaml中引入BgRow,然后在<ResourceDictionary>中加入<Bg:BgROW x:Key="bgRow"/>,最后添加<Setter Property="Background" Value="{Binding IsErr, Converter={StaticResource bgRow}}"/>对行背景色进行绑定
<Data