If you use custom images for DevExpress control elements in your web application, you should manually combine these images into a sprite image to benefit from the CSS sprites technique. Depending on the application's logic, you can combine images into a single (application specific) sprite image or multiple (control or product line specific) sprite images.
For each DevExpress control, set the required sprite image (and individual images contained within it) via one of the following approaches.
Via a control’s properties
Use the following properties to attach a sprite image to a control to display a sprite's parts for the control elements:
SpriteImageUrl - Specifies the path to a sprite image.
Height - Specifies the height of a separate element's image.
Width - Specifies the width of a separate element's image.
Top - Specifies thehe vertical offset within a sprite for a separate element's image.
Left - Specifies the horizontal offset within a sprite for a separate element's image.
The following image demonstrates the Properties Window with its properties as defined for the ASPxNavBar and its CollapseImage:
Notice that individual image settings are rendered as inline CSS styles embedded into an image's HTML tag. If too many images are defined via this approach, it may result in an increase in page size which might affect application performance.
When a sprite and its associated images are defined via a control’s properties, markup is added to the page. The code below illustrates the HTML markup generated for the ASPxNavBar’s collapse image.
Notice that individual image settings are rendered as inline CSS styles embedded into an image's HTML tag. If many images are defined via this approach, it may result in an increase in page size, which may affect application performance.
Via named CSS classes
You can define individual image settings using named CSS classes (which can be declared within the page markup or a linked CSS file) via the ImageSpriteProperties.CssClass property.
Each CSS class should contain attributes that specify the size of each image in the sprite (width and height, in pixels) and position within the sprite (horizontal and vertical offsets represented by negative values).This is the recommended approach when referring to a sprite image using CSS rules.
This approach uses the control’s SpriteImageUrl property to refer to a sprite image instead of defining it via CSS rules. Note that in this case, inline CSS settings are automatically rendered in each HTML image tag to define a sprite image, which increases the page size and overrides 'background-position' attributes for custom CSS classes. Be sure to add the '!important;' declaration to the 'background-position' CSS attributes in this case.
Was this page helpful?
Thanks for your feedback! Any other suggestions? Tell us here.