I have a rectangle that i want to fill with a color. When i write Fill = "#FFFFFF90"
it shows me an error:
Cannot implicitly convert type 'string' to 'System.Windows.Media.Brush
Please give me some advice.
The following list describes the different types of WPF brushes: SolidColorBrush: Paints an area with a solid Color. LinearGradientBrush: Paints an area with a linear gradient. RadialGradientBrush: Paints an area with a radial gradient. ImageBrush: Paints an area with an image (represented by an ImageSource object).
You could use the same mechanism the XAML reading system uses: Type converters
var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#FFFFFF90"); Fill = brush;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With