6

I am using DevExpress MVC and want to use a custom theme. I got it working to use a standard theme but it can't find my custom one.

I've created the custom theme using the ASP.NET 12.1 Theme Builder and copied it in my project to App_Themes/MyTheme

I've added it using this code:

[Web.config]

<devExpress>
    ...
    <themes enableThemesAssembly="true" styleSheetTheme="" theme="MyTheme" />
    ...
</devExpress>

[Global.asax.cs]

protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)
    {
        DevExpressHelper.Theme = "MyTheme";
    }

[_Layout.cshtml]

     @Html.DevExpress().GetStyleSheets( 
        new StyleSheet { ExtensionSuite = ExtensionSuite.NavigationAndLayout, Theme ="MyTheme" }, 
        new StyleSheet { ExtensionSuite = ExtensionSuite.Editors, Theme ="MyTheme" }, 
        new StyleSheet { ExtensionSuite = ExtensionSuite.HtmlEditor, Theme ="MyTheme" }, 
        new StyleSheet { ExtensionSuite = ExtensionSuite.GridView, Theme ="MyTheme" }, 
        new StyleSheet { ExtensionSuite = ExtensionSuite.PivotGrid, Theme ="MyTheme" },
        new StyleSheet { ExtensionSuite = ExtensionSuite.Chart, Theme ="MyTheme" },
        new StyleSheet { ExtensionSuite = ExtensionSuite.Report, Theme ="MyTheme" },
        new StyleSheet { ExtensionSuite = ExtensionSuite.Scheduler, Theme ="MyTheme"  }
    )

[Index.cshtml]

@Html.DevExpress().GridView(
    settings =>
        {
            ...
            settings.Theme = "MyTheme";
            ...
  }).Bind(Model.SearchResult).GetHtml()

When I use "Aqua" (standard theme) instead of "MyTheme" my control will be displayed in the Aqua theme. Using "MyTheme" first it just displayed the default standard theme, now it says "Cannot find the 'MyTheme' theme."

Can someone please help me? Thanks, Janina

tereško
  • 58,060
  • 25
  • 98
  • 150
Janina
  • 61
  • 1
  • 2

2 Answers2

1

Make sure you have compiled your theme and added a reference to it in your bin folder.

It is described in the documentation here

MikeB
  • 413
  • 4
  • 8
0

What version of Devexpress are you using?

Version <1.6 have a bug with custom themes.

Tristan
  • 342
  • 2
  • 13