Compartir a través de


VideoBrush Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Paints an area with video content.

Inheritance Hierarchy

System.Object
  System.Windows.DependencyObject
    System.Windows.Media.Brush
      System.Windows.Media.TileBrush
        System.Windows.Media.VideoBrush

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public NotInheritable Class VideoBrush _
    Inherits TileBrush
public sealed class VideoBrush : TileBrush
<VideoBrush .../>

The VideoBrush type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows Phone VideoBrush Initializes a new instance of the VideoBrush class.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone AlignmentX Gets or sets the horizontal alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public propertySupported by Silverlight for Windows Phone AlignmentY Gets or sets the vertical alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public propertySupported by Silverlight for Windows Phone Dispatcher Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public propertySupported by Silverlight for Windows Phone Opacity Gets or sets the degree of opacity of a Brush. (Inherited from Brush.)
Public propertySupported by Silverlight for Windows Phone RelativeTransform Gets or sets the transformation that is applied to the brush using relative coordinates. (Inherited from Brush.)
Public propertySupported by Silverlight for Windows Phone SourceName Gets or sets the name of the MediaElement to use as the source of the VideoBrush.
Public propertySupported by Silverlight for Windows Phone Stretch Gets or sets a value that specifies how the content of this TileBrush stretches to fit its tiles. (Inherited from TileBrush.)
Public propertySupported by Silverlight for Windows Phone Transform Gets or sets the transformation that is applied to the brush. (Inherited from Brush.)

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone CheckAccess Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetAnimationBaseValue Returns any base value established for a Silverlight dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone SetSource(CaptureSource) Sets the source of the VideoBrush using a video capture source
Public methodSupported by Silverlight for Windows Phone SetSource(MediaElement) Sets the source of the VideoBrush using a media file source from an intermediary MediaElement control.
Public methodSupported by Silverlight for Windows Phone SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Fields

  Name Description
Public fieldStatic memberSupported by Silverlight for Windows Phone SourceNameProperty Identifies the SourceName dependency property.

Top

Remarks

A detailed walkthrough of how to use a VideoBrush is documented in 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.

Silverlight 4 introduces an overload of SetSource(CaptureSource) that is used for webcam scenarios. For this scenario, you set the source video for a VideoBrush using a CaptureSource. For more information on obtaining a CaptureSource and webcam scenarios, see CaptureSource and VideoSink.

Examples

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

Run this sample

<Canvas
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  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>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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