For some time I’d wanted to find a way to make use of the skins provided with the DevExpress WinForms controls without deploying and loading the optional skin assemblies. If you just want to use one of the custom skins DevExpress provides, it may be overkill to ship and load 7MB of assemblies for this purpose.
Recently I was lucky enough to hang out with much of the team from DevExpress, as well as fellow members of the DX-Squad, at DevConnections in Las Vegas. Michael Proctor (who was interested in accomplishing something similar) and I spoke with Azret Botash, who works on the .NET controls at DevExpress. Azret indicated that it was already possible to load the WinForms skins without the optional skin assemblies. He then proceeded to download and install Reflector on a conference PC before disassembling one of the DX WinForms samples and highlighting a few of the key classes involved, such as SkinXmlCreator and SkinXmlLoader.
After returning home, I started digging through the samples that ship with DXperience and was able to assemble various pieces of the puzzle to make my own SkinBlobXmlFileCreator class. It descends from SkinXmlCreator and then uses some very basic code to load a skin directly from its .XML and .BLOB files rather than from an assembly. These .XML and .BLOB files ship with DXperience and are located here:
C:\Program Files\DevExpress 201X.Y\Components\Sources\DevExpress.BonusSkins\SkinData
C:\Program Files\DevExpress 201X.Y\Components\Sources\DevExpress.OfficeSkins\SkinData
C:\Program Files\DevExpress 201X.Y\Components\Sources\DevExpress.Utils\SkinData
Using this new class, you can load a skin with the following lines:
SkinBlobXmlFileCreator creator = new SkinBlobXmlFileCreator("VS2010", Application.StartupPath + "\\", "VS2010.skin.xml"); SkinManager.Default.RegisterSkin(creator); UserLookAndFeel.Default.SetSkinStyle("VS2010");
This works without deploying or referencing the BonusSkins assembly. Only the “VS2010.skin.xml” and “VS2010.blob” files are required.
You can download the source for the SkinBlobXmlFileCreator here.