0

I am trying to apply custom theme to my site collection but getting below error while applying:

Error CS0117 'SharePointTheme' does not contain a definition for 'customtheme'

Below is my code line:

var customtheme = "Custom Theme";
Web web = ctx.Web;
//ctx.Credentials = cred;
ctx.Load(web);
ctx.ExecuteQuery();
ThemeManager.ApplyTheme(ctx.Web, OfficeDevPnP.Core.Enums.SharePointTheme.customtheme)

1 Answer 1

1

As per this reference SharePointTheme.cs, SharePointTheme enum has below values only:

namespace OfficeDevPnP.Core.Enums
{
    public enum SharePointTheme
    {
        Blue,
        Orange,
        Red,
        Purple,
        Green,
        Gray,
        DarkYellow,
        DarkBlue,
        Teal
    }
}

You are receiving this error because there is no definition customtheme in above enum.


Also, check this documentation for applying a theme using CSOM API,

There's currently no supported CSOM API to programmatically apply a theme to a specific site. For information on applying custom themes to individual site collections see SharePoint site design and site script overview


Check other overloading methods for ApplyTheme() method at ThemeManager.cs which might help you with applying custom theme.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.