2

I have a simple Windows Form. In it, I've embedded a ChildXtraUserControl which derives from XtraUserControl (DevEx v10.1).

I'd like to skin the ChildXtraUserControl with 'Office 2010 Blue', and I'm expecting it to look bluish when I run the form. I've tried this two different ways but am unable to get it to work.

Attempt 1: Set the LookAndFeel in the ChildXtraUserControl, set the ChildXtraUserControl into a Windows Form Panel in the form

When I run this, I see only the Panel, which I've colored pale yellow.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        var devExUserControl = new DevExpressUserControl {Dock = DockStyle.Fill};
        panel1.Controls.Add(devExUserControl);
    }
}

public partial class ChildXtraUserControl : XtraUserControl
{
    public ChildXtraUserControl()
    {
        InitializeComponent();
        IntializeSkin();
    }

    private void IntializeSkin()
    {
        LookAndFeel.UseDefaultLookAndFeel = false;
        LookAndFeel.UseWindowsXPTheme = false;
        LookAndFeel.Style = LookAndFeelStyle.Skin;
        LookAndFeel.SkinName = "Office 2010 Blue";
    }
}

Attempt 2: I read on the DevEx Support Center that the ChildXtraUserControl could be in a DevExpress PanelControl, and the LookAndFeel set on the PanelControl

As before, I only see the pale yellow PanelControl. The post does seem like it was for a different DevEx version, but I thought it was worth a shot.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        panelControl1.LookAndFeel.UseDefaultLookAndFeel = false;
        panelControl1.LookAndFeel.UseWindowsXPTheme = false;
        panelControl1.LookAndFeel.Style = LookAndFeelStyle.Skin;
        panelControl1.LookAndFeel.SkinName = "Office 2010 Blue";

        var devExUserControl = new ChildXtraUserControl { Dock = DockStyle.Fill };
        panelControl1.Controls.Add(devExUserControl);
    }
}

public partial class ChildXtraUserControl : XtraUserControl
{
    public ChildXtraUserControl()
    {
        InitializeComponent();
    }
}

Does anyone have any ideas what I'm doing wrong? Thanks in advance.

ck.
  • 1,056
  • 1
  • 14
  • 25

1 Answers1

1

I managed to get this to work by using the second approach and modifying the Form1 constructor as shown.

    public Form1()
    {
        InitializeComponent();

        // add this line
        DevExpress.UserSkins.OfficeSkins.Register();

        panelControl1.LookAndFeel.UseDefaultLookAndFeel = false;
        panelControl1.LookAndFeel.UseWindowsXPTheme = false;
        panelControl1.LookAndFeel.Style = LookAndFeelStyle.Skin;
        panelControl1.LookAndFeel.SkinName = "Office 2010 Blue";

        var childXtraUserControl = new ChildXtraUserControl {Dock = DockStyle.Fill};
        panelControl1.Controls.Add(childXtraUserControl);
    }
ck.
  • 1,056
  • 1
  • 14
  • 25
  • Also, to get children DevEx controls (e.g. ComboBoxEdit) of the ChildXtraUserControl to be skinned the same way, I had to embed a StyleController in the ChildXtraUserControl (using the designer), set up the LookAndFeel on it, and set the StyleController property of each child control. – ck. Mar 25 '15 at 04:57