Using Value Converters in WPF without having to define them as resources first

后端 未结 4 967
春和景丽
春和景丽 2020-12-09 04:20

Is it possible to use value converters without having to define them beforehand as resources?

Right now I have


    

        
4条回答
  •  春和景丽
    2020-12-09 04:28

    In the case of singleton-type IValueConverters (e.g. they don't need any state from the current binding instance) I use static converters, i.e.:

    Converter={x:Static SomeNamespace:SomeConverter.Instance}
    

    There's also a great post by Dr. WPF on using a markup extension to make it cleaner inline here.

提交回复
热议问题