windowsforms-devexpress-dot-xtrabars-dot-docking2010-dot-views-dot-windowsui-dot-windowsuiview-1f8d4c9b.md
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.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public event CustomDrawBackButtonEventHandler CustomDrawBackButton
Public Event CustomDrawBackButton As CustomDrawBackButtonEventHandler
The CustomDrawBackButton event's data class is DevExpress.XtraBars.Docking2010.Views.WindowsUI.CustomDrawBackButtonEventArgs.
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.
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;
}
Dim myFont As New Font("Segoe UI", 9, FontStyle.Bold)
Dim myPen As New Pen(SystemColors.InactiveCaptionText, 3)
Private Sub WindowsUIView1_CustomDrawBackButton(sender As Object, e As DevExpress.XtraBars.Docking2010.Views.WindowsUI.CustomDrawBackButtonEventArgs) Handles WindowsUIView1.CustomDrawBackButton
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
End Sub
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;
}
}
Private Sub windowsUIView1_CustomDrawBackButton(sender As Object, e As DevExpress.XtraBars.Docking2010.Views.WindowsUI.CustomDrawBackButtonEventArgs)
If e.ButtonInfo.State = DevExpress.Utils.Drawing.ObjectState.Normal Then
e.DrawGlyph(Properties.Resources.backImage_32x32_normal)
e.Handled = True
End If
If e.ButtonInfo.State = DevExpress.Utils.Drawing.ObjectState.Hot Then
e.DrawGlyph(Properties.Resources.backImage_32x32_hovered)
e.Handled = True
End If
If e.ButtonInfo.Pressed Then
e.DrawGlyph(Properties.Resources.backImage_32x32_pressed)
e.Handled = True
End If
End Sub
See Also