I am trying to use a IValueConverter on the flowdocument of a richtextbox. However, ideally I'd like to be able to inject some dependencies into the converter on construction or perhaps with a setter of some sort. Previously I've been using an IoC to construct
a formatter-type object and can obviously specify the constructor dependency quite easily. However, I was hoping to use XAML and the IValueConverter as much as possible, but specifying the converter in the Grid.Resources requires a parameterless constructor.
Are there other ways in which I can do this or do I need to think about the problem differently.
In addition, because you cannot bind to a RichTextBox, I have introduced an AttachedProperty. Here's some code
Public Shared ReadOnly DocumentProperty As DependencyProperty =
Private Shared Function RichTextBoxFrameworkPropertyMetaData() As FrameworkPropertyMetadata
Dim metaData = New FrameworkPropertyMetadata
metaData.BindsTwoWayByDefault = True
metaData.AffectsRender = True
New PropertyChangedCallback(Sub(obj, e)
If _recursionProtection.Contains(Thread.CurrentThread) Then Return
Dim rtb = CType
View Complete Post