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 code

Paint with a SolidColorBrush in code

From the course: Windows Presentation Foundation 4: Brushes and Colors

Start my 1-month free trial

Paint with a SolidColorBrush in code

- [Narrator] In this example, I'll look at how to apply a brush to a brushable property. The brush I'll be working with is the solid color brush because that's the most common brush you'll encounter in WPF. In this first example, I'll write the solid color brush and apply it in C# code. Later in this chapter, I'll show you how to do the same thing in XAML. And for the item that I'm going to apply the brush to I'll work with some ellipses. I picked ellipses because they're simple, they have a fill property and a stroke property that can have a brush applied. It's a simple concept, but everything I show you in this video also applies to any of the other brushable properties on any of the other elements. The ellipses are not visible on the screen unless you mouse over them. You can see there here, and I'll click and you can see the ellipse appear. The other way to make them appear is to go to your XAML editor, find them in the editor, and click on them. You get the sizing handled and the…

Contents