From the course: Windows Presentation Foundation 4: Brushes and Colors
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Paint with a SolidColorBrush in XAML
From the course: Windows Presentation Foundation 4: Brushes and Colors
Paint with a SolidColorBrush in XAML
- [Voiceover] I find that when working with solid color brushes, it's more common to set them in XAML than to set them in your C# code. So that's what I'll look at in this movie and in the next movie. In this movie I'll look at how to use the more verbose syntax for setting the solid color brush in my XAML and in the next video I'll look at how to use a type converter to simplify it somewhat. I'm working with the same UI from the previous example. Here I have three ellipses inside this window, I want to set the fill property and the stroke property for this middle ellipse. Let's review what I did in the prior example. In my C# code I instantiated a brush, then I set the brush's color and on this last line here, I assigned the brush to the fill property. Here's how you do the same thing in XAML. Start with the ellipse, and I want to set the fill property. So I will add an ending element, then I'll go and use this syntax, which is called a property element. Essentially, this is the fill…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.