Skip to main content
.NET 6.0+

FileTypeFilterAttribute Class

Applied to file data business classes, interfaces and their properties. Specifies a file type filter which appears in the Open dialog’s “Files of type” box.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.Persistent.Base.v23.2.dll


[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Interface, AllowMultiple = true, Inherited = false)]
public class FileTypeFilterAttribute :


The File Attachments module supplies the File Property Editors. By default, these Property Editors are used for properties of the types that implement the DevExpress.Persistent.Base.IFileData interface. To load files, the FileDataPropertyEditor invokes the Open dialog. The FileTypeFilter attribute specifies a file type filter which will appear in the Open dialog’s “Files of type” box. It can be applied to a file data property whose type implements the IFileData interface or inherits from the DevExpress.Persistent.BaseImpl.FileAttachmentBase class. If the attribute is applied to a class of interface, then it has effect on a property whose name is passed to the FileAttachmentAttribute‘s FileAttachmentAttribute.FileDataPropertyName parameter.

The FileTypeFilter attribute has two constructors. The first constructor takes the filter description and a list of associated file extensions as the parameters. The second constructor has one more parameter, with which you can arrange the type filter strings in the required order, when multiple FileTypeFilter attributes are applied.

The file type filters defined via the FileTypeFilter attribute are reflected in the Application Model. For each file type filter defined by the FileTypeFilter attribute, a FileTypeFilters child node is added to the Application Model’s BOModel | <Class> | OwnMembers | <Member> node representing the target file data property. A FileTypeFilters child node comprises FileTypeFilter child nodes. Each FileTypeFilter child node represents a single file type filter. A FileTypeFilter, in turn, comprises Extension child nodes that define the extensions associated with a file type filter. You can define new and modify existing file type filters by editing the FileTypeFilters node via the Model Editor.


The following code snippet illustrates FileTypeFilter attribute use.

using DevExpress.Persistent.BaseImpl.EF;


public class CustomClass : BaseObject {
    [FileTypeFilter("Document files", 1, "*.txt", "*.doc")]
    [FileTypeFilter("Image files", 2, "*.bmp", "*.png", "*.gif", "*.jpg")]
    [FileTypeFilter("All files", 3, "*.*")]
    public virtual FileData Document { get; set; }

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.


If you have no access to the business class source to apply the attribute (e.g., when you use a built-in FileAttachmentBase), use the Application Model instead.

The following image shows the resulting Open dialog.


For general information on the FileAttachments module, refer to the File Attachments Module Overview topic.


Currently, the FileTypeFilterAttribute is supported in XAF Windows Forms applications only. So, it does not affect the Open dialogs invoked from XAF ASP.NET Web Forms and ASP.NET Core Blazor UI applications.


See Also