Style settings with dash in Tinymce v2 format meny



So the new tinymce editor, conveniently, all the examples of setting styles using anonymous objects in C# is using the example "color", but what do I do if I want to set another style, say text-align?

This will obviosuly not compile:

.StyleFormats(new {
   title = "Alignment",
   items = new[] {
      new {title = "Left", block = "p", styles = { text-align = "left"}},
      new {title = "Center", block = "p", styles = { text-align = "center"}}

I have tried various different strings with no success, like styles = "text-align: center". I am guessing there is one, but I am just not able to guess it.

Anyone have an idea how to achieve this?

Aug 23, 2019 12:25

Hi Erik,

The following worked for me (although, to be honest, I wasn't really expecting it to!):

        title = "Alignment",
        items = new[]
            new {title = "Left", block = "p", styles = new Dictionary<string, string> {{"text-align", "left"}}},
            new {title = "Center", block = "p", styles = new Dictionary<string, string> {{"text-align", "center"}}},
Edited, Aug 23, 2019 17:33


Yes it worked, and I suppose that makes sense.


Edited, Aug 23, 2019 17:35
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.