Partager via


WebBrowserBrush.SourceName Property

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

Gets the name of the source WebBrowser control that provides the HTML content.

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

Syntax

'Declaration
Public Property SourceName As String
public string SourceName { get; set; }
<WebBrowserBrush SourceName="webBrowserName"/>

Property Value

Type: System.String
The Name of the WebBrowser that provides the HTML content.

Remarks

You must set a name for the WebBrowser control, either in XAML or code prior to setting the SourceName property.

Examples

The following example shows how set the SourceName property of a WebBrowserBrush control.

    <UserControl x:Class="WebBrowserBrushEx.MainPage"
    xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="https://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="https://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="400" d:DesignWidth="412">
    <Grid x:Name="LayoutRoot" Background="LightBlue" MouseMove="LayoutRoot_MouseMove" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="40"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Storyboard x:Name="Spin" >
                <DoubleAnimation
                        Storyboard.TargetName="myTransform"
                        Storyboard.TargetProperty="Angle"
                        From="0" To="360" Duration="0:0:5" 
                        RepeatBehavior="Forever" />
            </Storyboard>
        </Grid.Resources>
        <TextBlock Margin="5" Text="Right-click to install the out-of-browser application" />
        <WebBrowser Grid.Row="1" Visibility="Visible" Name="WB1" Height="350" Width="350" Source="https://www.bing.com"  />

        <!-- Add Rectangle the same size as the WebBrowser control -->
        <Rectangle Grid.Row="1" x:Name="brush" Width="350" Height="350"  Visibility="Collapsed" 
                   MouseLeftButtonDown="brush_MouseLeftButtonDown"  >
            <Rectangle.Fill>
                <!-- Fill (set background) as an HTML Brush -->
                <WebBrowserBrush x:Name="htmlBrush" SourceName="WB1"/>
            </Rectangle.Fill>
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="myTransform" Angle="45" CenterX="175" CenterY="175" />
            </Rectangle.RenderTransform>

        </Rectangle>
     </Grid>
</UserControl>

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.