DataTrigger where value is NOT null?

后端 未结 12 635
野趣味
野趣味 2020-11-27 10:56

I know that I can make a setter that checks to see if a value is NULL and do something. Example:


  
    

        
12条回答
  •  情歌与酒
    2020-11-27 10:59

    Stop! No converter! I dont want to "sell" the library of this guy, but I hated the fact of doing converter everytime I wanted to compare stuff in XAML.

    So with this library : https://github.com/Alex141/CalcBinding

    you can do that [and a lot more] :

    First, In the declaration of the windows/userControl :

    
    

    then, in the textblock

    
          
              
              
                 
              
            
          
        
    

    The magic part is the conv:Binding 'MYValue==null'. In fact, you could set any condition you wanted [look at the doc].

    note that I am not a fan of third party. but this library is Free, and little impact (just add 2 .dll to the project).

提交回复
热议问题