VideoBrush Object

Paints an area with video content.

XAML
<VideoBrush .../>
Scripting
To create an object using scripting, see the CreateFromXAML method.

Properties

AlignmentX, AlignmentY, Name, Opacity, RelativeTransform, SourceName, Stretch, Transform

Methods

Equals, FindName, GetHost, GetValue, SetValue

Remarks

A detailed walkthrough of how to use a VideoBrush is documented in the Silverlight VideoBrush Overview.

A VideoBrush is a type of Brush object similar to a LinearGradientBrush or an ImageBrush. However, instead of painting an area with a solid color, a gradient, or an image, it paints an area with video content. This video content is provided by a MediaElement. Just like the other brush types, you can use a VideoBrush to paint the Fill of a shape such as a Rectangle or the geometry contents of a Path, the Background of a Canvas, or the Foreground of a TextBlock or Run.

To use a VideoBrush, you create a MediaElement, apply the VideoBrush to the object that you want to paint, and set the VideoBrush object's SourceName property to the Name of the MediaElement that you created.

Examples

The following example uses a VideoBrush to paint the Foreground of a TextBlock.

XAML
<Canvas
  xmlns="https://schemas.microsoft.com/client/2007"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml">
  
    <MediaElement 
      x:Name="butterflyMediaElement" 
      Source="sampleMedia/Butterfly.wmv" IsMuted="True"
      Opacity="0.0" IsHitTestVisible="False" />
      
    <TextBlock Canvas.Left="5" Canvas.Top="30"  
      FontFamily="Verdana" FontSize="120" 
      FontWeight="Bold" TextWrapping="Wrap"
      Text="Video">
      
        <!-- Paint the text with video. -->
        <TextBlock.Foreground>
          <VideoBrush SourceName="butterflyMediaElement" Stretch="UniformToFill" />
        </TextBlock.Foreground>
    </TextBlock>
    
</Canvas>

For more information, see the VideoBrush Overview.

See Also

VideoBrush Overview
Brush Overview
Silverlight Objects