WPF Trigger based on Object Type

前端 未结 5 941
自闭症患者
自闭症患者 2020-12-13 17:27

Is there a way to do a comparison on object type for a trigger?


         


        
5条回答
  •  旧巷少年郎
    2020-12-13 18:18

    Not a trigger but this worked for me. (The trigger-approach didn't as it can't create a checkbox for a string. This is pretty much Thomas Levesque's suggestion)

    using:

    xmlns:mscorlib="clr-namespace:System;assembly=mscorlib"
    

      A CheckBox or TextBox depending on the type:

    
          
                   
                        
                   
                      
                        
                    
           
    
    

    Note: for Greg Sansom's solution you either got to return the type as String or use mscorlib as above

提交回复
热议问题