Binding to element in WPF: can the Path expression do math?

后端 未结 5 1101
天命终不由人
天命终不由人 2021-01-31 09:34

I\'m trying to bind a control to the parent\'s Height/width property using ElementName and a Path. However, I don\'t want to bind to the actual height, but to exact

5条回答
  •  北海茫月
    2021-01-31 10:01

    No it can't you should use binding converters

    public class MyConverter : IValueConverter
    {
    public object Convert(object value, Type  targetType,
          object parameter, CultureInfo culture)
      {
          return (int)value/2;
      }
    
      public object ConvertBack(object value, Type targetType,
          object parameter, CultureInfo culture)
      {
        return null;
      }
    }
    

提交回复
热议问题