Suppose I have class I want to reference in XAML.
public class MyConverter
{
public static readonly MyConverter Default = new MyConverter();
...
};
And then in XAML I can reference it either
<Label Content="{Binding Text,Converter={x:Static local:MyConverter.Default}"/>
or
<local:MyConverter x:Key="MyConverter"/>
...
<Label Content="{Binding Text,Converter={StaticResource local:MyConverter}"/>
Which way is more efficient?
I doubt anything here will be more effecient than other but the key difference here is what is actually going on:
MyConverter
MyConverter
and using it. I believe first one might couple percents faster (or what do you mean by efficient?) but this difference won't give you much profit. I would choose option #1 if you already have a static field. Also as far as I remember x:Static
still is not available in Silverlight.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With