VideoBrush Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
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)
XMLNS for XAML: Not mapped to an xmlns.
Syntax
Public NotInheritable Class VideoBrush _
Inherits TileBrush
public sealed class VideoBrush : TileBrush
<VideoBrush .../>
The VideoBrush type exposes the following members.
Constructors
Name | Description | |
---|---|---|
VideoBrush | Initializes a new instance of the VideoBrush class. |
Top
Properties
Name | Description | |
---|---|---|
AlignmentX | Gets or sets the horizontal alignment of content in the TileBrush base tile. (Inherited from TileBrush.) | |
AlignmentY | Gets or sets the vertical alignment of content in the TileBrush base tile. (Inherited from TileBrush.) | |
Dispatcher | Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.) | |
Opacity | Gets or sets the degree of opacity of a Brush. (Inherited from Brush.) | |
RelativeTransform | Gets or sets the transformation that is applied to the brush using relative coordinates. (Inherited from Brush.) | |
SourceName | Gets or sets the name of the MediaElement to use as the source of the VideoBrush. | |
Stretch | Gets or sets a value that specifies how the content of this TileBrush stretches to fit its tiles. (Inherited from TileBrush.) | |
Transform | Gets or sets the transformation that is applied to the brush. (Inherited from Brush.) |
Top
Methods
Name | Description | |
---|---|---|
CheckAccess | Determines whether the calling thread has access to this object. (Inherited from DependencyObject.) | |
ClearValue | Clears the local value of a dependency property. (Inherited from DependencyObject.) | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
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.) | |
GetAnimationBaseValue | Returns any base value established for a Windows Phone dependency property, which would apply in cases where an animation is not active. (Inherited from DependencyObject.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GetValue | Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
ReadLocalValue | Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.) | |
SetSource(CaptureSource) | Sets the source of the VideoBrush using a video capture source | |
SetSource(MediaElement) | Sets the source of the VideoBrush using a media file source from an intermediary MediaElement control. | |
SetValue | Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Extension Methods
Name | Description | |
---|---|---|
SetSource(Camera) | Overloaded. Sets the VideoBrush source to the camera. (Defined by CameraVideoBrushExtensions.) | |
SetSource(Object) | Overloaded. Sets the VideoBrush source to the camera. (Defined by CameraVideoBrushExtensions.) |
Top
Fields
Name | Description | |
---|---|---|
SourceNameProperty | Identifies the SourceName dependency property. |
Top
Remarks
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.
Examples
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>
Version Information
Windows Phone OS
Supported in: 8.1, 8.0, 7.1
Platforms
Windows Phone
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.
See Also
Reference
System.Windows.Media Namespace
Other Resources
Capturing video for Windows Phone 8