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 video using the VisualBrush

Paint with video using the VisualBrush

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

Start my 1-month free trial

Paint with video using the VisualBrush

- [Narrator] In this example, I'll look at how to take the streaming video from the media element, and use that as a brush in my application. There is no concept of a video brush in WPF, but remember, that the visual brush can render any part of the visual tree, and the media element is part of the visual tree. Here's how I'll implement my application. I have a media element here. Here it is. It has the source of this Turbines.mov file, and then in my code behind, on the button click event handler, I just call play, so that'll start the video playing. The app looks like this. Now, I'll go over to my UI, I'll click on the ellipse, I'll add a visual brush, where the visual is going to be a binding to an element named "media one". Now I'll remove this fill property, and you can see the first frame of the video is shown here, and the first frame is now showing on my ellipse. Now to make this more dramatic, I'll copy the ellipse, and paste it in a few more times. Then run the application…

Contents