WPF Tooltip Visibility

前端 未结 4 1709
梦毁少年i
梦毁少年i 2020-12-06 16:17

How can I ensure that a button\'s Tooltip is only visible when the button is disabled?

What can I bind the tooltip\'s visibility to?

4条回答
  •  醉酒成梦
    2020-12-06 17:02

    A slightly modified answer for what David Ward has proposed. Here is the full code

    Add a value converter to resouces like this

    
        
    
    

    Then define following xaml

    The value converter looks like this

    [ValueConversion(typeof(bool), typeof(bool))]
      public class NegateConverter : IValueConverter
      {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
         return  !((bool)value);
        }
    
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
          throw new NotImplementedException();
        }
      }
    

提交回复
热议问题