poy*_*poy 1 c# wpf ivalueconverter visual-studio-2012
简单的问题:
为什么我必须要constructor一个IValueConverter?
我不是在问,为什么我必须要一个empty constructor,我问为什么我必须要一个?
如果我有:
public class PauseButtonValueConverter : MarkupExtension, IValueConverter
{
//public PauseButtonValueConverter() //<- Uncomment this and the error is fixed
//{
//}
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
然后,我VS2012给了我编译时错误:No constructor for type 'PauseButtonValueConverter' has 0 parameters.
如果我添加constructor,错误是固定的.