Wednesday, 26 June 2013

Visual Brush in WPF

A VisualBrush is used to fill UI elements. The following code uses a VisualBrush to fill a rectangle.we can  , define a simple or complex UI element and assign it to the VisualBrush.Visual property using VisualBrush.we can then use the VisualBrush to create interesting effects, such as reflection and magnification. This example shows how to use the VisualBrush class with a Visual. Here I am using media element as visual. A Visual object usually hosts one container panel such as a Grid or StackPanel and on this container.
Here is the xaml code :

<Window x:Class="wpftheme.Window1"
        Title="Window1" Height="350" Width="300" Initialized="Window_Initialized">
            <Ellipse Height="100" Width="100" Name="elipsemedia" >
                    <VisualBrush TileMode="None">
                            <MediaElement Source="D:\TestingDB\wpftheme\wpftheme\Image\Wildlife.wmv" />

Here i am used Ellipse.fill property for video brush.this fill property  sets the Brush that specifies how the shape's interior is painted.