Problem with Binding (Conversion class) RRS feed

  • Question

  • I have this problem: I've written this XAML <ListBoxVisibility="{BindingIsDataLoaded,Converter=BoolToVisibility}" ItemsSource="{Binding ...}" .............../>

    and I've written this C# class:


    classBoolToVisibilityConverter: IValueConverter



    publicobjectConvert(objectvalue, TypetargetType, objectparameter, System.Globalization.CultureInfoculture)















    publicobjectConvertBack(objectvalue, TypetargetType, objectparameter, System.Globalization.CultureInfoculture)





    However I get this error (not at Runtime): "Errore 1 Il TypeConverter per "IValueConverter" non supporta la conversione da una stringa." which means "The TypeConverter for "IValueConverter" doesn't support conversion from a string"...in fact I'm not trying to convert from a string, but from a bool value (IsDataLoaded is boolean). Why this happens?

    Tuesday, August 27, 2013 1:23 PM

All replies

  • Hi,

    I guess you declaring the converter wrong here.

    I guess you have declared the Converter as a local resource . something like this :

                           <local:BoolToVisibilityConverter x:Key="BoolToVisibility" />

    In the code you should use like this :

    Converter={StaticResource BoolToVisibility}}" ItemsSource="{Binding ...}" .............../>

    - Girija

    Please mark responses as answered if it helped you.. This helps others... - Girija Shankar Beuria

    Tuesday, August 27, 2013 1:40 PM
  • write this code in your xaml to access the converter in xaml

    and after that add resource of this like 

                <app:BoolToVisibilityConverter x:Key="myConverterKey" />

    now bind the value with this key like 

    Value="{Binding Converter={StaticResource myConverterKey}}"

    then your converter work fine . 

    Tuesday, August 27, 2013 2:08 PM