expressappframework-112792-app-shell-and-base-infrastructure-icons-add-and-replace-icons.md
XAF applications can display icons next to Actions, navigation items, Detail View captions, and business class names. You can add custom icons to your application, replace built-in XAF icons, and configure which UI elements display icons.
This help topic shows you how to:
XAF uses image sources to locate and load application icons. Understanding how image sources work helps you control which icons appear in the UI and troubleshoot display issues.
| Image Source | Description | Requirements |
|---|---|---|
| File Image Source | References icons stored in a folder on disk. Images are copied to the output directory at build time. | Set each image file’s Copy to Output Directory to Copy always. |
| DevExpress.Images.v25.2 Assembly Resource Image Source | Contains all built-in XAF icons. Default image source. | None. |
To view the available image sources in your application:
A typical XAF application includes the following autogenerated image sources:
Before adding icons to your application, ensure your image files meet the following requirements:
XAF applications support both SVG and raster images (PNG, JPG, BMP). The recommended format is SVG. If you have to use raster images, we recommend PNG.
Use SVG images for better display on High DPI screens.
Embed custom images into assemblies as resources rather than using file references.
When using image files, keep file names under 260 characters. This is important for ClickOnce deployment, which can create long installation paths. If an image path exceeds 260 characters, the image is unavailable, and the issue is logged in the Log File.
Raster Image Size
| Image size | Image suffix | Description |
|---|---|---|
| 16x16 | none | Standard-sized images used for Business Classes |
| 32x32 | “32x32” | Used as Large Icons in the Navigation Bar and Ribbon UI |
| 48x48 | “48x48” | Used by the Validation Module |
SVG Image Size
An SVG image size is determined by a control or set in the Model Editor.
Follow guidelines below when you name image files:
| Image | Name Description |
|---|---|
| Employee.png | Do not include a size suffix for 16x16 raster images. |
| Employee_32x32.png | Add a size suffix to 12x12, 24x24, 32x32 and 48x48 raster images. |
| Office2013\Employee.png | Raster images are part of the DevExpress.Images ‘s Colored collection. To use images from another collection, add its name without spaces to an image name as prefix. You can see the available collections in the Common PNG Images tab of the Image Picker dialog window. |
| Employee.svg | SVG images. |
For business classes, use two PNG images (ImageName.png and ImageName_32x32.png) or one SVG image (ImageName.svg) for vector graphics. Template Kit enables SVG images for all new XAF WinForms applications. To use PNG images instead, set the UseSvgImages property to false.
Two types of DevExpress themes are available for ASP.NET Core Blazor applications: Fluent and Classic. XAF ships icon sets for both theme types and automatically switches icons based on the theme. You can use the IconType property to select the icon set. Available options include:
AutoDefault value. XAF switches icons according to the currently selected theme.BlazorXAF uses icons from the Classic theme set.FluentXAF uses icons from the Fluent theme set.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor;
public class MySolutionBlazorApplication : BlazorApplication {
public MySolutionBlazorApplication() {
// ...
IconType = IconType.Fluent;
}
}
An XAF application with the Fluent icon set
An XAF application with the Standard icon set
To add custom icons to your XAF application, create an Images folder in your module project and add your image files as embedded resources.
In your module project (for example, SolutionName.Module ), create an Images folder if it does not exist.
Add your image files to the Images folder.
For each image file, set the Build Action property to Embedded Resource in the file’s properties.
The framework automatically creates an Assembly Resource Image Source for the Images folder in your module. Icons from this folder are available throughout your application for use with business classes, Actions, and UI elements.
If you have icons stored in a separate assembly:
Open the Model Editor in your module project.
Navigate to the ImageSources node.
Add a new AssemblyResourceImageSource node.
Set the Assembly property to the name of your image assembly.
Set the Folder property to the folder name containing the images.
Add a reference to the image assembly in all your module and application projects.
XAF includes default icons for common UI elements. To replace a built-in icon with your custom version, add an image with the same name to your module’s Images folder.
In your module project (for example, SolutionName.Module ), create an Images folder if it does not exist.
Add your custom image file to the Images folder. Name it exactly the same as the built-in icon you want to replace.
Set the Build Action property to Embedded Resource for the image file.
The framework searches for icons in the order specified by the Index property of image sources. If your module’s image source has a lower index than the source containing the original icon, your custom icon will be used instead.
To ensure your custom icons take precedence over built-in icons:
Open the Model Editor for your application project (for example, SolutionName.Win or SolutionName.Blazor.Server ).
Navigate to the ImageSources node.
Locate the child nodes that correspond to different image sources.
Set the Index property for each image source node. Lower index values have higher priority.
Note
Embedding images as resources is more reliable than using file-based image sources. While you can add images to an application project’s Images folder, we recommend that you use embedded resources in module projects.
After adding icons to your application, assign them to business classes, actions, and other UI elements.
To display icons in the Navigation System and Tabbed MDI tabs, configure these Application Model properties:
| Property | Value | UI Item |
|---|---|---|
| IModelRootNavigationItems.ShowImages | true | Navigation items |
| IModelOptionsWin.ShowTabImage | true | Tab images (WinForms) |
| IModelOptionsBlazor.ShowTabImage | true | Tab images (ASP.NET Core Blazor) |
| EnableLayoutGroupImages | true | Tabbed layout groups |
The Application Model has an ImageName property for UI elements that can display icons. For example, the BOModel | <Class> node’s ImageName property controls the icon shown for a business class in Detail Views and other UI elements.
Tip
Use these naming rules:
"ImageName" (for example, "Department")"SubfolderName.ImageName" (for example, "MyBusinessClasses.Department")To set an icon using the Model Editor:
Open the Model Editor and navigate to the element you want to configure.
Locate the ImageName property.
Click the ellipsis button to open the Image Picker dialog.
Browse and select the icon you want to use.
You can assign icons programmatically instead of using the Model Editor.
Tip
Use these naming rules:
"ImageName" (for example, "Department")"SubfolderName.ImageName" (for example, "MyBusinessClasses.Department")Apply the ImageNameAttribute to your business class:
File: SolutionName.Module/BusinessObjects/Department.cs
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Xpo;
namespace SolutionName.Module.BusinessObjects {
[ImageName("Department")]
public class Department : BaseObject {
public Department(Session session) : base(session) { }
//...
}
}
Use the ActionBase.ImageName property in your controller:
File: SolutionName.Module/Controllers/MyController.cs
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
namespace SolutionName.Module.Controllers {
public class MyController : ViewController {
public MyController() {
var myAction = new SimpleAction(this, "MyAction", PredefinedCategory.View) {
Caption = "My Action",
ImageName = "Action_Refresh"
};
}
}
}
See Also
How to: Set Images and Captions for Enumeration Values