1 创建一个类
public class A
{
private string _result;
public string Result
{
get { return _result; }
set { _Title = result; }
}
}
2 创建一个 ColorConverter 类 继承自 IValueConverter 类
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
//throw new NotImplementedException();
if(value as string == "Success")
{
return "Green";
}
else
{
return "Red";
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
3 在 xaml 文件中写:
<Window.Resources>
<local:Color