<Button Margin="2" Width="10" >
<Button.Background>
<SolidColorBrush Color="{Binding Path=MarkColor}"></SolidColorBrush>
</Button.Background>
</Button>
这样即可绑定
但是需要注意的是这里的Color是System.Windows.Media.Color不是Drawing.Color
也可以直接Background绑定,但是需要进行一个convert
public class Matrix2Len : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return 0;
else
{
List<List<double>> data = (List<List<double>>)value;
return data[0].Count/1000;
}
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}