There is a usual TextBox in which the text is written. I need the following:
I select a part of the text with the mouse and click on the "Italic" button, then <i> added before the start of the text selection, </i> added at the end of the selection.
Question: how to determine the text selected with the mouse for further work with it?
UPD1:
I am using MVVM + Catel, Catel.Fody model
My view:
<TextBox Grid.Row="2" Grid.Column="1" MaxLines="255" AcceptsReturn="True" AcceptsTab="True" Text="{Binding Content, UpdateSourceTrigger=PropertyChanged}" TextChanged="OnTextChanged" SelectedText="{Binding SelectedText, UpdateSourceTrigger=PropertyChanged}"/> My model:
public ViewModel() { BoldText = new Command(OnBoldText); ItalicText = new Command(OnItalicText); } public Command BoldText { get; set; } public Command ItalicText { get; set; } public string SelectedText { get; set; } private void OnBoldText() { } private void OnItalicText() { } Now the problem is that if I set the view to SelecteedText in SelecteedText then the tab in the program simply stops opening. If I remove this property, then everything works.
SelectedText="", if you add anything to the brackets, then everything stops working. - Leksor