2012-05-17 188 views
0

'StringToVisibilityConverter' 不实现接口构件 'System.Windows.Data.IValueConverter.Convert(对象,System.Type的, 对象,System.Globalization.CultureInfo)'不实现接口成员(C#)

任何想法这有什么不对?据我所知我的进口是正确的

public class StringToVisibilityConverter : IValueConverter 
{ 
    public object Convert(object value, Type targetType, 
          object parameter, CultureInfo culture) 
    { 
     if (value != null && value is string) 
     { 
      var input = (string)value; 
      if (string.IsNullOrEmpty("Name")) 
      { 
       return Visibility.Collapsed; 
      } 
      else 
      { 
       return Visibility.Visible; 
      } 
     } 

     return Visibility.Visible; 
    } 
+3

你正确读取该错误信息?您缺少ConvertBack()。 –

+0

刚刚才意识到,这里只是清晨;) –

回答

1

是啊,你还需要,当你继承的IValueConverter有这样的方法:

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
2

你也需要实现ConvertBack方法。 IValueConverter

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
{ 
//Your code goes here 
} 
相关问题