This
<TextBlock Text="{MyMethod mystringparameter}" />
<TextBlock Text="{MyMethod {Binding ElementName=myWindow, Path=MyString}} />
wont work, you can't use a method like that in xaml. You can do one of the following three thing:
1)
use ObjectDataProvider[
^]
2) Create an attached property and do some reflection
3) Create your own markup extension
I suggest you do none of the above right now, and instead tell me what you're trying to achieve I'm sure we can find another better way than using a method.
Ok I suspected that was what you were trying to do. I'll not go over how you can do this here but refer you to an article that covers that subject:
Simple WPF Localization[
^]
There is close to no explenation of how it's done, but since you've already looked abit at
MarkupExtension
I'm sure you can look at the code and quickly figure out how it works. It also shows how you can avoid the need to register a namespace Like Wayne suggested in his answer.