[英]Does not implement interface member (C#)
'StringToVisibilityConverter' does not implement interface member 'System.Windows.Data.IValueConverter.Convert(object, System.Type, object, System.Globalization.CultureInfo)'
'StringToVisibilityConverter'未实现接口成员'System.Windows.Data.IValueConverter.Convert(object,System.Type,object,System.Globalization.CultureInfo)'
Any idea what's wrong with this? 知道这有什么问题吗? As far as I know my imports are correct
据我所知我的进口是正确的
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;
}
You need to implement the ConvertBack method as well. 您还需要实现ConvertBack方法。 IValueConverter
IValueConverter
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
//Your code goes here
}
From the documentation http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter.aspx I see that must implement and ConvertBack. 从文档http://msdn.microsoft.com/zh-cn/library/system.windows.data.ivalueconverter.aspx中,我看到必须实现和ConvertBack。
The issue could appear event the class CultureInfo is not from System.Globalization.CultureInfo and is a custom class. 如果CultureInfo类不是来自System.Globalization.CultureInfo,而是一个自定义类,则可能出现此问题。
是的,在继承IValueConverter时,还需要使用以下方法:
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.