Click here to Skip to main content
15,742,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In this code convert "string[]" to "string",and display on "TextBox". ,using "IValueConverter";I find the code have error,but IDE running correctly.
<src:StringArrayConverter x:Key="stringArrayConverter"/>
<!--"ConverterParameter" is "char"-->
<TextBlock Text="{Binding Path=Authors,
    Converter={StaticResource stringArrayConverter},

class StringArrayConverter:IValueConverter
    public object Convert(object value,Type targetType,object parameter,CultureInfo cultureInfo)
        string[] str = (string[])value;
        //how can convert "char" to "string"
        string separator = (string)parameter;
        return string.Join(separator, str);
    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo cultureInfo)
        string str = (string)value;
        char c = (char)parameter;
        //how can "Split" Method receive a char?
        return str.Split(c);
Updated 7-Jun-10 1:48am

1 solution

I think you might be able to do this:

In your Convert method:

return new string(value);

In your ConvertBack method:

return ((string)value).ToArray();
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900