I've just updated the corresponding Support Center ticket and want to share one more advanced example on using the built-in ImageLoader API with you. Before reading further, please learn more on this helper class from its docs or from my previous post on the same subject:
In the latest XAF v15.2+, there is a universal and platform-agnostic way to replace the default validation images globally in the application by handling the static DevExpress.ExpressApp.Utils > ImageLoader >CustomGetImageInfo event. Consider the following example code that can be added in YourSolutionName.Module/Module.cs file:
[C#]Open in popup windowusing DevExpress.ExpressApp.Utils;
namespace MainDemo.Module {
public sealed partial class MainDemoModule : ModuleBase {
private const string STR_CustomErrorImageName = "BO_Skull";
public MainDemoModule() {
InitializeComponent();
/* Dennis: The images corresponding to validation errors may have the followng names by default:
"Error" or "State_Validation_Invalid" + size suffix
"Warning" or "State_Validation_Warning" + size suffix
"Information" or "State_Validation_Information" + size suffix
*/
ImageLoader.CustomGetImageInfo += (s, e) => {
bool isLargeImage = e.ImageName.EndsWith("_32x32") || e.ImageName.EndsWith("_48x48");
if(e.ImageName.Contains("State_Validation_Invalid") || e.ImageName == "Error") {
e.Handled = true;
e.ImageInfo = isLargeImage ?
ImageLoader.Instance.GetLargeImageInfo(STR_CustomErrorImageName) :
ImageLoader.Instance.GetImageInfo(STR_CustomErrorImageName);
}
};
}
This simple code will work in both ASP.NET and WinForms apps.
Even thought there is a built-in image used in the example, you can usually replace it with any other image. Refer to the event's documentation for a more complex use-case scenario where the image is obtained from the database.
