windowsforms-8885-controls-and-libraries-ribbon-bars-and-menu-examples-popup-menus-how-to-populate-a-menu-and-ribbon-gallery-with-devexpress-skin-items-and-localize-them.md
The DevExpress.XtraBars.Helpers.SkinHelper class allows you to populate an existing RibbonGalleryBarItem or any menu (PopupMenu or BarSubItem) with items that correspond to DevExpress skins. If an end-user clicks any item, the corresponding skin is applied via the static Default Look and Feel object.
This example demonstrates how to use the SkinHelper class to populate a RibbonGalleryBarItem and PopupMenu with skin items, and how to localize skin captions via a Localizer object. See Localizing WinForms Controls via Localizer Objects to learn more.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using DevExpress.XtraBars.Localization;
namespace HowToUseBarSkinHelper {
public partial class Form1 : RibbonForm {
public Form1() {
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e) {
BarLocalizer.Active = new MyBarLocalizer();
SkinHelper.InitSkinGallery(ribbonGalleryBarItem1, true);
SkinHelper.InitSkinPopupMenu(popupMenu1);
}
}
// Custom localizer that changes skin captions
public class MyBarLocalizer : BarLocalizer {
public override string GetLocalizedString(BarString id) {
if (id == BarString.SkinCaptions) {
//Default value for BarString.SkinCaptions:
//"|DevExpress Style|Caramel|Money Twins|DevExpress Dark Style|iMaginary|Lilian|Black|Blue|Office 2010 Blue|Office 2010 Black|Office 2010 Silver|Office 2007 Blue|Office 2007 Black|Office 2007 Silver|Office 2007 Green|Office 2007 Pink|Seven|Seven Classic|Darkroom|McSkin|Sharp|Sharp Plus|Foggy|Dark Side|Xmas (Blue)|Springtime|Summer|Pumpkin|Valentine|Stardust|Coffee|Glass Oceans|High Contrast|Liquid Sky|London Liquid Sky|The Asphalt World|Blueprint|"
string defaultSkinCaptions = base.GetLocalizedString(id);
string newSkinCaptions = defaultSkinCaptions.Replace("|DevExpress Style|", "|My Favorite Skin|");
return newSkinCaptions;
}
return base.GetLocalizedString(id);
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars.Helpers
Namespace HowToUseBarSkinHelper
Partial Public Class Form1
Inherits RibbonForm
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
SkinHelper.InitSkinGallery(ribbonGalleryBarItem1, True)
SkinHelper.InitSkinPopupMenu(popupMenu1)
End Sub
End Class
End Namespace