Skip to main content

How to: Apply Alpha Blending to the Control's Background

The following sample code assigns background images to the XtraNavBar and its groups. The NavBarGroup.BackgroundImage and NavBarControl.GroupBackgroundImage properties are used for this purpose. The NavBarControl.BeginUpdate and NavBarControl.EndUpdate methods are used to avoid repeated redrawing when changes are implemented.

The image below shows the nav bar before and after the code below has been executed.

AlphaBlending - Backgrounds

navBarControl1.BeginUpdate();
// Assigning an image to the control's background.
navBarControl1.BackgroundImage = Image.FromFile("C:\\Images\\Textures\\controlBack.gif");
// Making the control's background transparent.
navBarControl1.Appearance.Background.BackColor = Color.FromArgb(0, 0, 0, 0);
// Assigning an image to the background of the groups.
navBarControl1.GroupBackgroundImage = Image.FromFile("C:\\Images\\Textures\\groupsBack.gif");
// Making the background transparent.
navBarControl1.Appearance.GroupBackground.BackColor = Color.FromArgb(0, 0, 0, 0);
navBarControl1.EndUpdate();