I have a bindinglist with INotifyPropertyChanged interface. Things work fine. This bindinglist is a list of file names that is bound to a listbox. I want only the name displayed, not the whole path, but when I select a file name and load the file, I need the whole path.
I am using IValueConverter for this purpose where is use Path.GetFileName property to change full path to file name. Bindings are correct, but my bindinglist is not changing values as I want them to. I am pasting IValueConverter code below. Please let me know what is wrong with this code. i referred conversion here.
[ValueConversion(typeof(string), typeof(string))]
public class pathtoname : IValueConverter
{
public object Convert(object value, Type targetType, object parameter ,CultureInfo culture)
{
BindingList<string> ls = value as BindingList<string>;
ls.Select(x => "WW");
return ls;//all values should be WW. But they are not.(debugger)
}
public object ConvertBack(object value, Type targetType, object parameter,CultureInfo culture)
{
return null;
}
}
EDIT: Values are converted now. But now how to retrieve back the whole path? Shall I keep 2 lists? One for full path and one with name like here. Any better solution?