Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind to a StaticResource with a Converter?

I want to use a Converter to change the value of a StaticResource before assigning it to a property. Is there a way to simulate a Binding that will just set the value of the StaticResource after converting it?

Something like {Binding Value={StaticResource myStatic}, Converter={StaticResource myConverter}}?

like image 673
Ignacio Soler Garcia Avatar asked May 18 '13 10:05

Ignacio Soler Garcia


1 Answers

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...

like image 189
Marc Avatar answered Oct 05 '22 03:10

Marc