How to bind to a StaticResource with a Converter?
This works:
<TextBox Text="{Binding Source={StaticResource myStatic},
Converter={StaticResource myConverter},
Mode=OneWay}" />
Note that you have to bind one way, because the binding requires a path attribute otherwise. This makes sense, as otherwise the binding would have to replace the whole resource...
Ignacio Soler Garcia
I am now acting as a delivery manager focused on the three main pillars of software creation: People, Procedures and Code working mainly with Javascript teams (React / Redux / Node) building applications 100% in the cloud with CI/CD, etc. I am open to proposals, let's talk. Previously I used to be an experienced technical leader commanding .Net technologies, passionate about Agile methodologies and a people person.
Updated on May 17, 2020Comments
-
Ignacio Soler Garcia about 4 years
I want to use a
Converter
to change the value of aStaticResource
before assigning it to a property. Is there a way to simulate aBinding
that will just set the value of theStaticResource
after converting it?Something like
{Binding Value={StaticResource myStatic}, Converter={StaticResource myConverter}}
? -
Marcin Tarsier over 6 yearsFor properties, which probably won't change at runtime from XAML side this
Mode=OneWay
isn't required, e.g. forGrid.Row
. Anyway - I finally got ridden of magic numbers from XAML in favor of enums, thanks!