I want to shorten settings bindings
{Binding Source={x:Static properties:Settings.Default}, Path=Password}
To something like
{settingsBinding Password}
By moving part of declaration to global resource dictionary. But it seems that I can’t declare bindings here. Any ideas how to pull this off?
I want at least make it like this
{Binding Source={StaticResource Settings}, Path=Password}
So I don’t have to include properties namespace every time.
To get the first syntax, you have to derive from
Bindingand specify the source:You can then use:
{xxx:SettingsBinding Password}. However, you’ll still have to specify the namespace of this class. I won’t recommend this approach though: bindings tend to be quite verbose but you know what is happening since the syntax is always the same.To get the second syntax you desire, simply define your
x:Staticas a resource, eg:You can now reference it using
StaticResource.