Adding ListStyles

6 posts, 1 answers
  1. Sebastian
    Sebastian avatar
    9 posts
    Member since:
    Feb 2015

    Posted 18 Feb 2015 Link to this post

    Hi I tried to add ListStyles to a RadDocument so that they are shown in the RadRichTextBoxRibbonUi.

    foreach (var style in listStyles)
                {                               
                    ListStyle newList = RadDocument.AddCustomListStyle(style);               
                    RadDocument.ListStyles.Add(newList);
                    RadDocument.ListManager.RegisterListStyleIfNecessary(newList);                               
                }


    That is what I'm doing at the moment but it doesn't works.

  2. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 19 Feb 2015 Link to this post

    Hello Sebastian,

    You should add the ListStyle to the RadDocument using the DocumentList class. The code snippet below demonstrates how to achieve this:
    RadDocument doc = new RadDocument();
    ListStyle newListStyle = doc.AddCustomListStyle(list);
    DocumentList documentList = new DocumentList(newListStyle, doc);           
    this.radRichTextBox.Document = doc;

    In addition, more information about lists and list styles you can find in the List Styles article in our documentation.

    Regards,
    Tanya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sebastian
    Sebastian avatar
    9 posts
    Member since:
    Feb 2015

    Posted 20 Feb 2015 Link to this post

    public RadDocument RadDocument
            {
                get
                {
                    return this.editor.Document;
                }
                set
                {
                    this.editor.Document = value;               
                }
            }
    What I've forgot to Post the var RadDocument is the Current RadDocument of my RadRichTextBox
  5. Sebastian
    Sebastian avatar
    9 posts
    Member since:
    Feb 2015

    Posted 20 Feb 2015 Link to this post

    foreach (var style in listStyles)
     {                                               
                    ListStyle newList = RadDocument.AddCustomListStyle(style);
                    DocumentList documentList = new DocumentList(newList, RadDocument);
                    RadDocument.ListStyles.Add(newList);
                    RadDocument.ListManager.RegisterListStyleIfNecessary(newList);                               
                }
                this.editor.Document = RadDocument;
    this is my current cdoe for adding the ListStyles but it doesn't work.
  6. Answer
    Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 23 Feb 2015 Link to this post

    Hi Sebastian,

    Please, refer to the snippet below, which is demonstrating how to create a List and add it to the RadDocument:
    ListStyle list = new ListStyle();
    list.StyleLink = "Numbered";
     
    for (int levelIndex = 0; levelIndex < 9; levelIndex++)
    {
        bool isEven = (levelIndex % 2) == 0;
        ListLevelStyle level = new ListLevelStyle();
        level.StartingIndex = 1;
        level.NumberingFormat = ListNumberingFormat.Decimal;
        level.LevelText = isEven ? "{" + levelIndex + "}." : "o";
        level.ForeColor = Color.FromRgb(34, 144, 233);
        level.Indent = 48 + (levelIndex * 24);
     
        list.Levels.Add(level);
    }
     
    RadDocument doc = new RadDocument();
    ListStyle newListStyle = doc.AddCustomListStyle(list);
    DocumentList documentList = new DocumentList(newListStyle, doc);

    If you are still experiencing difficulties with this, it would be great if you sent us more details - what is the code for creating the ListStyles, what is not working - it the style not appearing in the document or you get some an error. If it is possible an example project would be great.

    I am looking forward to hearing from you.

    Regards,
    Tanya
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. Sebastian
    Sebastian avatar
    9 posts
    Member since:
    Feb 2015

    Posted 24 Feb 2015 Link to this post

    Thanks it works now.
    My misstake was that I doesn't set the StartingIndex and the LevelText of the LevelStyle.
Back to Top
UI for WPF is Visual Studio 2017 Ready