Share via


SetSource (ImageBrush)

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

Sets the source value of an ImageBrush object with downloaded content.

object.SetSource(downloader, part)

Arguments

downloader

Downloader

The Downloader object that contains the downloaded content.

part

string

The name of the specific part of the downloaded content package. When the downloaded content package is a .zip file, part refers to the contents of a file name in downloader. If the downloaded content does not represent packaged content, set part to an empty string.

Managed Equivalent

SetSource - use a stream obtained from WebClient as input.

Remarks

The SetSource method sets the downloaded image content to the ImageSource property of an ImageBrush object. Equivalent SetSource methods exist on Image (for Source) and MediaElement (for Source). The first parameter, downloader, identifies the Downloader object that represents the downloaded content. The second parameter, part, identifies the specific part to retrieve from the downloaded content. If the downloaded content does not represent packaged content, such as a .zip file, part must be set to an empty string.

Example

The following JavaScript example shows how to use the SetSource method to set the Source property of an ImageBrush object to the downloaded content.

// Event handler for the Completed event.
function onCompletedImageBrush(sender, eventArgs)
{
    // Retrieve the ImageBrush object.
    var myImageBrush = sender.findName("myImageBrush");

    // Set the ImageSource property from the gear_large.png part of a larger .zip download.
    myImageBrush.setSource(sender, "gear_large.png");
}

Applies To

ImageBrush