How to bind to a StaticResource with a Converter?

前端 未结 1 1465
心在旅途
心在旅途 2020-12-15 16:06

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

相关标签:
1条回答
  • 2020-12-15 16:49

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

    0 讨论(0)
提交回复
热议问题