Ivan Crojach Karačić
Ivan Crojach Karačić

Reputation: 1911

Send value to ValueConverter

I have this ValueConverter:

public class LabelConverter : IValueConverter
{
    public object Convert(object value,
                          Type targetType,
                          object parameter,
                          System.Globalization.CultureInfo culture)
    {            
        return ApplicationSettings.getTranstaltion(value.ToString());
    }
}

It is used to convert some labels according to the selected language. The value that should be passed in is the labelName which is then looked up in the database. Then the propper translation is chosen and sent back. Here are the two attempts that I have used but which both failed:

 <telerik:ChartLegend Header="{Binding Converter={StaticResource LabelConverter},
                              ConverterParameter='lblLegend'}"
                              x:Name="ChartLegend1"
                              />

<telerik:ChartLegend Header="{Binding ElementName=ChartLegend1, Path=Tag
                              Converter={StaticResource LabelConverter}"
                              x:Name="ChartLegend1"
                              Tag="lblLegend"
                              />

Any help?

Upvotes: 0

Views: 95

Answers (1)

Jens H
Jens H

Reputation: 4632

First thing that comes to my mind is to check try adding the binding mode explicitly with Mode=TwoWay.

[Edit] Additionally you should check if check if ApplicationSettings.getTranstaltion() throws an exception that is silently choked by Silverlight. Lastly, could value ever be null? In that case value.ToString() might throw an exception.

Silverlight often handles exceptions silently without the user noticing it (or due to your Visual Studio exception settings), so in both of the latter cases the converter might not do something without ever presenting an exception to you.

Upvotes: 1

Related Questions