Skip to main content
A newer version of this page is available. .

DXImageHelper.GetImageSource(String, ImageSize, ImageType) Method

Retrieves the specified image from the image library. This method allows you to display only the raster images.

Namespace: DevExpress.Xpf.Core

Assembly: DevExpress.Xpf.Core.v21.2.dll

NuGet Package: DevExpress.Wpf.Core

Declaration

public static ImageSource GetImageSource(
    string id,
    ImageSize imageSize,
    ImageType imageType = ImageType.Colored
)

Parameters

Name Type Description
id String

A raster image identifier.

imageSize DevExpress.Utils.Design.ImageSize

A predefined image size.

Optional Parameters

Name Type Default Description
imageType DevExpress.Utils.Design.ImageType 1

A predefined image type.

Returns

Type Description
ImageSource

A ImageSource object that is the retrieved raster image.

Remarks

Use the DevExpress Image Picker tool to see images that are included in the DevExpress.Images.v21.2 assembly and copy an image’s path to a clipboard.

The following code sample uses the DXImageHelper.GetImageSource method to obtain a raster image from the DevExpress.Images.v21.2 assembly and specify the image’s size and type:

<dx:ThemedWindow ...
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="30px"/>
            <RowDefinition Height="32px"/>
        </Grid.RowDefinitions>
        <Button Content="Display Image" Click="Button_Click" Width="150" Grid.Row="0"/>
        <Image x:Name="pngImage" Height="32px" Grid.Row="1"/>
    </Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using DevExpress.Utils.Design;
// ...
private void Button_Click(object sender, RoutedEventArgs e) {
    pngImage.Source = DXImageHelper.GetImageSource("Add", ImageSize.Size32x32, ImageType.GrayScaled);
}

Note

You can obtain an image by its ID only if this image exists in all image sets.

Refer to the following topic for more information: DevExpress Image Gallery.

See Also