how to format and create a word counter

Hello everyone

I am implementing a RichTextBoxAdv but I don't know how to do something 

  • I do not how to bind my view model to three buttons, to format to bold, italic and underline 
  • how do a create a word counter on my VM
  • open the richtextbox when creating a new note


this is my vm

        public ICommand ExitCommand { getset; }
    public ICommand NewNotebookCommand { getset; }
    public ICommand NewNoteCommand { getset; }
    public ObservableCollection<Notebook> Notebooks { getset; }
    public ObservableCollection<Note> Notes { getset; }
 
    DateTime date = DateTime.Now;
 
    private Notebook _SelectedNoteBook;
    public Notebook SelectedNoteBook {
        get { return _SelectedNoteBook; }
        set {
            if (_SelectedNoteBook != value) {
                _SelectedNoteBook = value;
                RaisePropertyChanged();
                GetNotes();
            }
        }
    }
 
 
    public NotesWindowVM() {
 
        Notes = new ObservableCollection<Note>();
        Notebooks = new ObservableCollection<Notebook>();
 
        ExitCommand = new Command(() => {
            Application.Current.Shutdown();
        });
        NewNotebookCommand = new Command(() => {
            CreateNewNotebook();
        });
        NewNoteCommand = new HelperCommand {
            ExecuteDelegate = x => CreateNewNote(SelectedNoteBook.Id),
            CanExecuteDelegate = x => SelectedNoteBook != null
        };
 
        GetNoteBooks();
    }
 
    private void CreateNewNote(int NotebookId) {
        Note note = new() {
            NotebookId = NotebookId,
            CreatedAt = DateTime.Now,
            UpdatedAt = DateTime.Now,
            Title = $"Created on {DateTime.Now}"
        };
        Database.Insert(note);
 
        GetNotes();
    }
 
    private void CreateNewNotebook() {
        Notebook notebook = new() { Name = "New Notebook" };
        Database.Insert(notebook);
 
        GetNoteBooks();
    }
 
    private void GetNoteBooks() {
 
        var notebooks = Database.Read<Notebook>();
 
        Notebooks.Clear();
        foreach (var item in notebooks) {
            Notebooks.Add(item);
        }
    }
 
    private void GetNotes() {
 
        if (SelectedNoteBook != null) {
            var notes = Database.Read<Note>().Where(
                n => n.NotebookId == SelectedNoteBook.Id)
                .ToList();
 
            Notes.Clear();
            foreach (var item in notes) {
                Notes.Add(item);
            }
        }
    }
}
Any help would be appreciated 

2 Replies 1 reply marked as answer

PS Premkumar Sundaramoorthy Syncfusion Team May 17, 2021 12:46 PM UTC

Hi Eduardo,

Thanks for using Syncfusion product,

We are working to prepare a sample as per your requirement. We will update you with further details on 18th May 2021.

Please let us know if you have any other questions.

Regards,
Premkumar 



KG Kalaivannan Ganesan Syncfusion Team May 19, 2021 07:04 AM UTC

Hi Eduardo,

Thanks for your patience,

To achieve your requirement of binding character format (bold, italic, and underline) and word count properties with multiple notes (SfRichTextBoxAdv). We have just changed the DataContext instated of binding it to the view model.

We have prepared the sample to demonstrate the same, which can be downloaded from the below location.
https://www.syncfusion.com/downloads/support/forum/165481/ze/SfRichTextBox_Sample1157754913

Please let us know if you need any further assistance.

Regards,
Kalaivannan
 


Marked as answer
Loader.
Up arrow icon