Condividi tramite


WebBrowserBrush Class

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

Provides a brush that renders the currently hosted HTML.

Inheritance Hierarchy

System.Object
  System.Windows.DependencyObject
    System.Windows.Media.Brush
      System.Windows.Media.TileBrush
        System.Windows.Controls.WebBrowserBrush

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

Syntax

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

The WebBrowserBrush type exposes the following members.

Constructors

  Name Description
Public method WebBrowserBrush Initializes a new instance of the WebBrowserBrush class.

Top

Properties

  Name Description
Public property AlignmentX Gets or sets the horizontal alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public property AlignmentY Gets or sets the vertical alignment of content in the TileBrush base tile. (Inherited from TileBrush.)
Public property Dispatcher Gets the Dispatcher this object is associated with. (Inherited from DependencyObject.)
Public property Opacity Gets or sets the degree of opacity of a Brush. (Inherited from Brush.)
Public property RelativeTransform Gets or sets the transformation that is applied to the brush using relative coordinates. (Inherited from Brush.)
Public property SourceName Gets the name of the source WebBrowser control that provides the HTML content.
Public property Stretch Gets or sets a value that specifies how the content of this TileBrush stretches to fit its tiles. (Inherited from TileBrush.)
Public property Transform Gets or sets the transformation that is applied to the brush. (Inherited from Brush.)

Top

Methods

  Name Description
Public method CheckAccess Determines whether the calling thread has access to this object. (Inherited from DependencyObject.)
Public method ClearValue Clears the local value of a dependency property. (Inherited from DependencyObject.)
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method 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 method 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 method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method GetValue Returns the current effective value of a dependency property from a DependencyObject. (Inherited from DependencyObject.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ReadLocalValue Returns the local value of a dependency property, if a local value is set. (Inherited from DependencyObject.)
Public method Redraw Forces the brush to asynchronously redraw itself.
Public method SetSource Sets the source of the content for the WebBrowserBrush.
Public method SetValue Sets the local value of a dependency property on a DependencyObject. (Inherited from DependencyObject.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Fields

  Name Description
Public fieldStatic member SourceNameProperty Identifies the SourceName dependency property.

Top

Remarks

WebBrowserBrush is a type of Brush object similar to a VideoBrush. However, instead of painting an area with video content, it paints an area with HTML content. This HTML content is provided by a WebBrowser control. Just like the other brush types, you can use a WebBrowserBrush to paint the following:

NoteNote:

You can only use WebBrowserBrush in a Silverlight 4 or later out-of-browser application or in a Silverlight 5 in-browser trusted application.

To use a WebBrowserBrush, you do the following:

  1. Create a WebBrowser control and set its Source property.

  2. Apply the WebBrowserBrush to the object that you want to paint.

  3. Set the WebBrowserBrush object's SourceName property to the name of the WebBrowser that you created.

If the content in the WebBrowser changes, you must call the Redraw method to update the WebBrowserBrush.

WebBrowserBrush can only be used in applications that run outside the browser. If you use it in an application that runs in the browser, WebBrowserBrush is transparent and does not contain placeholder content.

Examples

The following example shows how to use a WebBrowserBrush control. In this example, the WebBrowserBrush updates its content when the user moves the mouse.

Private Sub LayoutRoot_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Input.MouseEventArgs)
    WBB1.Redraw()
End Sub
private void LayoutRoot_MouseMove(object sender, MouseEventArgs e)
{
    WBB1.Redraw();
}
<StackPanel x:Name="LayoutRoot" Background="Blue" MouseMove="LayoutRoot_MouseMove">
    <WebBrowser Name="WB1" Source="Hello.html" Height="150" Width="150" />
    <Rectangle Height="150" Width="150" >
        <Rectangle.Fill>
            <WebBrowserBrush SourceName="WB1" Opacity=".5" x:Name="WBB1"/>
        </Rectangle.Fill>
    </Rectangle>
</StackPanel>

Version Information

Silverlight

Supported in: 5, 4

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.