I'm fairly new to WPF, so please bear with me.
I am trying to customize the presentation of the various elements of a FlowDocument
in a RichTextBox
(RTB). WPF controls are lookless, so as I understand it I should be able to define the look for every child in the Document
.
Would I define the template for this in the RTB? Separate templates for each item (Paragraph
, Section
, Run
, etc) as resources? Let's say, for sake of argument, that I want a red border around every (see edit one) Section
, the word "Paragraph:" before every Paragraph
with a Margin="5"
, and every Run
to be in Consolas.
EDIT ONE:
I learn more here from asking the wrong question than the right one. It seems I never ask what I'm really trying to do the first time out the gate. Who knows, maybe I'll learn.
I am trying to define a DataTemplate
or an ItemTemplate
(I think) similar to a ListBox
. The ultimate goal is a "source view" HTML editor in an RTB. I want a Paragraph XAML element to render like this in the RTB:
<p>
Lorem ipsum stackus overflowum
</p>
... and a Run would render like this:
<span style="font-weight:bold">clarity is important when asking questions</span>
... and so on with the different XAML elements.
Some of that you can do with styles
E.G.
Now the word Paragraph: before every paragraph I don't think you can do that with styles
The short answer is that you can't apply templates to these elements because they don't inherit from ControlTemplate.