VideoBrush Class

May 11, 2014

Paints an area with video content.

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)
XMLNS for XAML: Not mapped to an xmlns.

public sealed class VideoBrush : TileBrush
<VideoBrush .../>

The VideoBrush type exposes the following members.

  NameDescription
Public methodVideoBrushInitializes a new instance of the VideoBrush class.
Top

  NameDescription
Public propertyAlignmentXGets or sets the horizontal alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public propertyAlignmentYGets or sets the vertical alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public propertyDispatcherGets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertyOpacityGets or sets the degree of opacity of a Brush. (Inherited from Brush.)
Public propertyRelativeTransformGets or sets the transformation that is applied to the brush using relative coordinates. (Inherited from Brush.)
Public propertySourceNameGets or sets the name of the MediaElement to use as the source of the VideoBrush.
Public propertyStretchGets or sets a value that specifies how the content of this TileBrush stretches to fit its tiles. (Inherited from TileBrush.)
Public propertyTransformGets or sets the transformation that is applied to the brush. (Inherited from Brush.)
Top

  NameDescription
Public methodCheckAccessDetermines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodClearValueClears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAnimationBaseValueReturns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodReadLocalValueReturns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSetSource(CaptureSource)Sets the source of the VideoBrush using a video capture source
Public methodSetSource(MediaElement)Sets the source of the VideoBrush using a media file source from an intermediary MediaElement control.
Public methodSetValueSets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public Extension MethodSetSource(Camera)Overloaded. Sets the VideoBrush source to the camera. (Defined by CameraVideoBrushExtensions.)
Public Extension MethodSetSource(Object)Overloaded. Sets the VideoBrush source to the camera. (Defined by CameraVideoBrushExtensions.)
Top

  NameDescription
Public fieldStatic memberSourceNamePropertyIdentifies the SourceName dependency property.
Top

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.

You can use a VideoBrush with a MediaElement to play a video file, PhotoCamera to display the camera viewfinder, and CaptureSource to display video from the camera.

To use VideoBrush with 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.

To display the camera preview, like what you would see in a camera viewfinder, use the SetSource method to apply the instantiated PhotoCamera object to the VideoBrush. For more information, see How to create a base camera app for Windows Phone 8.

To display video from the camera, set the source video for a VideoBrush using a CaptureSource. For more information on obtaining a CaptureSource, see How to record video in a camera app for Windows Phone 8.

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


<MediaElement x:Name="butterflyMediaElement" 
Source="sampleMedia/Butterfly.wmv" IsMuted="True"
Opacity="0.0" IsHitTestVisible="False" Grid.Row="2" />

<TextBlock FontFamily="Verdana" FontSize="120" 
FontWeight="Bold" TextWrapping="Wrap"
Text="Video" Grid.Row="2">     
    <!-- Paint the text with video. -->
    <TextBlock.Foreground>
        <VideoBrush SourceName="butterflyMediaElement" Stretch="UniformToFill" />
    </TextBlock.Foreground>
</TextBlock>


Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Show:
© 2014 Microsoft