Have you tried using the methods that were clearly declared in the answer to your linked question, or do you copy without looking? Maybe something like this?:
TextBlockEx textBlockEx = new TextBlockEx();
textBlockEx.SetFormattedText(textBlockEx, new Run() { Text = "Hello World" });
UPDATE >>>
You really should ask every thing at once, rather than asking additional questions once your question had been answered. I can 't even provide a full answer to your second question, as you removed the Binding.Path
and Source
from the Binding
. To create your Binding
in code:
Binding binding = new Binding("PropertyOfYourDataSourceObject");
binding.Source = YourDataSourceObject;
binding.Converter = new SomeConverter();
textBlockEx.SetBinding(TextBlockEx.FormattedTextProperty, binding);
Please refer to the How to: Create a Binding in Code page on MSDN for further help.