WPF valueconverter中的设计时错误

时间:2014-04-16 17:53:20

标签: .net wpf ivalueconverter

我有一个转换器类:

Imports System.Windows.Markup

Public Class ValueToColorConverter
    Inherits MarkupExtension
    Implements IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
        Dim v As Double = System.Convert.ToDecimal(value)
        If v > 0 Then
            Return New SolidColorBrush(System.Windows.Media.Color.FromRgb(70, 120, 50))
        Else
            Return Brushes.White
        End If
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As System.Type, ByVal parameter As Object, ByVal culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
        Throw New System.NotImplementedException()
    End Function

    Public Overrides Function ProvideValue(ByVal serviceProvider As System.IServiceProvider) As Object
        Return Me
    End Function
End Class

我在XAML中使用它:

<local:ValueToColorConverter x:Key="ValueToColorConverter" />

Visual Studio在设计时显示在错误列表中

No constructor for type 'ValueToColorConverter' has 0 parameters

项目构建正常,转换器在运行时运行良好。 为什么在设计时显示错误以及如何删除错误?

0 个答案:

没有答案