CalcBinding icon indicating copy to clipboard operation
CalcBinding copied to clipboard

Null-conditional operator support and null

Open maurosampietro opened this issue 8 years ago • 3 comments

To calculate the visibilty of a control i'm using CalcBinding something like 'A?.B?.C > 0'.

I get a binding error saying "Value produced by BindingExpression is not valid for target property.; Value=''"

I also tried 'A != null and A.B != null and A.B.C > 0' but i can't get it to work.

So the question: is Null-conditional operator supported? Is it null supported in comparisons?

Thanks

P.S. - A naive converter works just fine

public class CarouselVisibility : BaseConverter, IValueConverter
{
   public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
   {
       var vm = value as ViewModel;
       return vm?.A?.B?.C?.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
   }
   public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
   {
      throw new NotImplementedException();
   }
}

maurosampietro avatar Sep 25 '17 12:09 maurosampietro

Try

'A != {x:Null} and A.B != {x:Null} and A.B.C > 0'  

keytrap-x86 avatar Dec 13 '20 21:12 keytrap-x86

This is some 3 years late but thanks anyway.

On 13 Dec 2020, at 22:18, Keytrap [email protected] wrote:

 Try

'A != {x:Null} and A.B != {x:Null} and A.B.C > 0'
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

maurosampietro avatar Dec 13 '20 21:12 maurosampietro

I discovered CalcBindings yesterday. Hope it'll help some futur readers

keytrap-x86 avatar Dec 13 '20 22:12 keytrap-x86