I have the following DependencyProperty which is of type Brush. I am trying to set the default value for the PatternBrushProperty.
public Brush PatternBrush
{
get => (Brush)GetValue(PatternBrushProperty);
set => SetValue(PatternBrushProperty, value);
}
public static readonly DependencyProperty PatternBrushProperty =
DependencyProperty.Register("PatternBrush", typeof(Brush), typeof(MyCustomControl),
new UIPropertyMetadata(defaultPatternBrush));
private static SolidColorBrush defaultPatternBrush
= new((Color)ColorConverter.ConvertFromString("#C5D4E3"));
When I try to execute the application, I get the following error:
System.InvalidOperationException Message='#FFC5D4E3' is not a valid value for property 'Color'.
I have tried different methods to specify the default brush but have had no success.
Is there a way to reference a SolidColorBrush in a resource dictionary to set the value?