Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

WindowsUIView.CustomDrawBackButton Event

Fires whenever the Back button needs to be displayed and allows you to manually draw this button.

Namespace: DevExpress.XtraBars.Docking2010.Views.WindowsUI

Assembly: DevExpress.XtraBars.v24.2.dll

NuGet Package: DevExpress.Win.Navigation

#Declaration

public event CustomDrawBackButtonEventHandler CustomDrawBackButton

#Event Data

The CustomDrawBackButton event's data class is DevExpress.XtraBars.Docking2010.Views.WindowsUI.CustomDrawBackButtonEventArgs.

#Remarks

Back buttons are automatically displayed when navigating to child containers within the WindowsUIView (see the Application Hierarchy and Module Navigation topic). By default, the Back button is drawn as a black circle with back arrow within. Handle the CustomDrawBackButton event to re-draw this button.

The code and image below illustrate an example of a manually drawn back button.

DocumentManager - CustomDrawBackButton

Font myFont = new Font("Segoe UI", 9, FontStyle.Bold);
Pen myPen = new Pen(SystemColors.InactiveCaptionText, 3);
private void windowsUIView1_CustomDrawBackButton(object sender, DevExpress.XtraBars.Docking2010.Views.WindowsUI.CustomDrawBackButtonEventArgs e) {
    e.GraphicsCache.DrawRectangle(myPen, e.Bounds);
    e.GraphicsCache.DrawString("Back", myFont, SystemBrushes.InactiveCaptionText, new PointF(25, 59));
    e.DrawGlyph(global::myApplication.Properties.Resources.undo_32x32);
    e.Handled = true;
}

To replace the default Back button image with your own custom image for all the button’s visual states (normal, pressed, hovered), use the following code.

private void windowsUIView1_CustomDrawBackButton(object sender, DevExpress.XtraBars.Docking2010.Views.WindowsUI.CustomDrawBackButtonEventArgs e) {
    if (e.ButtonInfo.State == DevExpress.Utils.Drawing.ObjectState.Normal) {
        e.DrawGlyph(Properties.Resources.backImage_32x32_normal);
        e.Handled = true;
    }
    if (e.ButtonInfo.State == DevExpress.Utils.Drawing.ObjectState.Hot) {
        e.DrawGlyph(Properties.Resources.backImage_32x32_hovered);
        e.Handled = true;
    }
    if (e.ButtonInfo.Pressed) {
        e.DrawGlyph(Properties.Resources.backImage_32x32_pressed);
        e.Handled = true;
    }   
}
See Also