❔ Custom DataTemplate for TextElements or alternative approaches
In WPF I'm working on a customized RichTextBox that will add TextElements that are bound to view models. I want to DataTemplates for this, but you can't put TextElements in a DataTemplate.
I've been looking into DataTemplate and FrameworkTemplate to see how they work, but its quite involved and maybe I'm over thinking this.
I want to be able to supply, in xaml preferably, a collection of mappings between a partially configure DataType and a template that will be bound to it.
This is the code I have for the association at the moment, making a copy of the DataContext is easy enough, but I don't know a what to do to make a copy of the ElementTemplate and maintain the binding information.
2 Replies
My aim is to make it so I can easily add new type associations and how they will be rendered in the FlowDocument
Seems this is doable to a limited extent by implementing ICloneable and using MemberwiseClone
This limits its usage to custom types
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.