WPF Visibility of a UI element based on combo selection

后端 未结 2 1664
日久生厌
日久生厌 2020-12-03 14:32

Trying to show a label only when a certain item in a combo is selected. Code should pretty much explain it.

    
               


        
2条回答
  •  孤城傲影
    2020-12-03 15:16

    There are two issues here. First the default visibility should be specified in the style. But even with that it won't work because the binding on the trigger is comparing a SelectedValue, a ComboBoxItem object with a string object and that will never be equivalent. To keep the example simple, I've placed appropriate values in the ComboBoxItem's Tag properties. Although the actual implementation of the comparison will likely vary based on the specific needs of the app.

        
            Don't show the label
            Show the label
        
    
        
    

提交回复
热议问题