Search code examples
c#wpfdatatemplatecontroltemplateflowdocument

WPF: Defining "Templates" for Elements Not Inherited From Control


In this post I tried to find a way to re-template the contents of a FlowDocument. I've done several hours of research, and eventually come to this documentation on Control.Template property:

The ControlTemplate specifies the appearance of a Control; if a Control does not have a ControlTemplate, the Control will not appear in your application.

I call shenanigans.

The Paragraph, Run, Section, List, Table, and so forth all "appear in my application" but since they inherit from System.Windows.ContentElement instead of System.Windows.Controls.Control none of them have a Template property that I can use to redefine the visual tree of the control.

Is there any way to change the visual presentation of these elements?


Solution

  • It is not possible to template the ContentElements, and its not intended.

    But you can use

    <BlockUIContainer/>
    

    for templated Controls within a FlowDocument.