wpf-devexpress-dot-xpf-dot-printing-d02dc116.md
An object that provides an image and its display name.
Namespace : DevExpress.Xpf.Printing
Assembly : DevExpress.Xpf.Printing.v25.2.dll
NuGet Package : DevExpress.Wpf.Printing
public class ImageGalleryItem :
ImmutableObject
Public Class ImageGalleryItem
Inherits ImmutableObject
When you register a custom image editor (see RegisterImageEditorInfo(String, ImageEditorOptions, String)) to edit the XRPictureBox‘s content in Print Preview, you can specify the PredefinedImages image collection. This collection is displayed in the image editor and enables end users to select one of the predefined images.
Create the ImageGalleryItem objects to populate the PredefinedImages image collection. Specify the Image and DisplayName (optionally) properties for each item.
The following code snippet demonstrates how you can specify the PredefinedImages collection.
using System.Collections.Generic;
using System.IO;
using DevExpress.Xpf.Printing;
using System.Drawing;
//...
Dictionary<string, Image> images = new Dictionary<string, Image>();
foreach (var file in Directory.GetFiles("Images/Flags", "*.png")) {
Image img = Image.FromFile(file);
if (img != null) {
string imageName = Path.GetFileNameWithoutExtension(file);
images.Add(imageName, img);
}
};
ImageEditorOptions imageEditorOptions = new ImageEditorOptions() {
AllowLoadImage = false,
AllowChangeSizeOptions = false,
AllowDraw = false,
AllowClear = true
};
foreach (var image in images)
imageEditorOptions.PredefinedImages.Add(new ImageGalleryItem(image.Value, image.Key));
EditingFieldExtensions.Instance.RegisterImageEditorInfo("Nationality", imageEditorOptions, "Nationality");
Option Infer On
Imports System.Collections.Generic
Imports System.IO
Imports DevExpress.Xpf.Printing
Imports System.Drawing
'...
Private images As New Dictionary(Of String, Image)()
For Each file In Directory.GetFiles("Images/Flags", "*.png")
Dim img As Image = Image.FromFile(file)
If img IsNot Nothing Then
Dim imageName As String = Path.GetFileNameWithoutExtension(file)
images.Add(imageName, img)
End If
Next file
Dim imageEditorOptions As New ImageEditorOptions() With {
.AllowLoadImage = False,
.AllowChangeSizeOptions = False,
.AllowDraw = False,
.AllowClear = True
}
For Each image In images
imageEditorOptions.PredefinedImages.Add(New ImageGalleryItem(image.Value, image.Key))
Next image
EditingFieldExtensions.Instance.RegisterImageEditorInfo("Nationality", imageEditorOptions, "Nationality")
Note
If you do not set display names for all Image Gallery Items, search is not available in the image editor’s predefined collection.
Object DevExpress.Utils.ImmutableObject ImageGalleryItem
See Also