实例报错如下:
InvalidOperationException: “#FF877F7F”不是属性“ScrollBarForeground”的有效值。
把下面文句中的Brush
public class ControlAttachProperty
{
public static readonly DependencyProperty ScrollBarForegroundProperty =
DependencyProperty.RegisterAttached("ScrollBarForeground", typeof(Brush), typeof(ControlAttachProperty), new PropertyMetadata(null));
public static void SetScrollBarForeground(DependencyObject element, Brush value)
{
element.SetValue(ScrollBarForegroundProperty, value);
}
public static Brush GetScrollBarForeground(DependencyObject element)
{
return (Brush)element.GetValue(ScrollBarForegroundProperty);
}
}
改为SolidColorBrush
public class ControlAttachProperty
{
public static readonly DependencyProperty ScrollBarForegroundProperty =
DependencyProperty.RegisterAttached("ScrollBarForeground", typeof(SolidColorBrush), typeof(ControlAttachProperty), new PropertyMetadata(null));
public static void SetScrollBarForeground(DependencyObject element, SolidColorBrush value)
{
element.SetValue(ScrollBarForegroundProperty, value);
}
public static SolidColorBrush GetScrollBarForeground(DependencyObject element)
{
return (SolidColorBrush)element.GetValue(ScrollBarForegroundProperty);
}
}
即可。