Como posso alterar a cor de fundo do texto selecionado na caixa Rich text wpf c #
Como posso exibir texto html paraRichTextBox
ao controle?
Na verdade, eu quero mudar a cor de fundo do texto selecionadoRichTextBox
em c # wpf. Eu tentei este código, mas não está exibindo texto formatado.
Por favor me ajude ... Obrigado antecipadamente!
void rtbTextEditor_SelectionChanged(object sender, RoutedEventArgs e)
{
SelectionText = rtbTextEditor.Selection.Text.Trim();
if (SelectionText != string.Empty)
{
if (VisualEditor.Document.Body != null)
{
//VisualEditor is web browser
VisualEditor.Document.Body.InnerHtml = @"""<html><body><FONT style=""BACKGROUND-COLOR: #ffff00""><bold>""" + rtbTextEditor.Selection.Text + @"""</Bold></FONT></body></html>""";
VisualEditor.Document.ExecCommand("SelectAll", false, null);
rtbTextEditor.Document.Blocks.Add(new Paragraph(new Run(VisualEditor.Document.Body.InnerText.ToString())));
}
}
}