0

I'm currently trying to create a simple program in WPF to make cards for a custom card game. Some of the descriptions feature rich text (like bold and italics) to highlight important things. The effect and the flavor text are copied into the same RichTextBox for aesthetic and convenience, which is why I need to be able to copy rich text from an input into a line/paragraph that is added to the display. Here is the code:

private void EffectInput_TextChanged(object sender, TextChangedEventArgs e)
    {
        TextRange temp = new TextRange(EffectInput.Document.ContentStart, EffectInput.Document.ContentEnd);
        Console.WriteLine(temp.Text);

        effectText.Inlines.Clear();

        effectText.Inlines.Add(new Run(temp.Text));

        updateDescription();
    }

private void updateDescription()
    {
        Description.Document.Blocks.Clear();

        Description.Document.Blocks.Add(effectText);
        Description.Document.Blocks.Add(flavorText);
    }

I managed to make it work with the Text inside the box, but I can't find a way to also copy the format of the text. Can anyone help me?

  • In case I didn't explain myself properly, the variable "EffectInput" is a richtextbox. I'm trying to copy the content AND the formatting into a paragraph or inline variable so I can then use that to build the content of another richtextbox. – Jose Gonzalez-Belmonte Oct 18 '17 at 20:01
  • Have you tried setting the FontStyle, FontWeight, etc properties? – Nick Fisher Nov 16 '17 at 15:37

0 Answers0