Programming, WPF

IValueConverter

If you’re making an WPF Visual Basic application and make a custom IValueConverter for the first time you’ll probably see this message

“The name <your_class> does not exist in the namespace “clr-namespace:<your_application>

Here’s a screenshot from the XAML Designer:temp1

The fix is surprisingly easy:

  1. Change that line to “<local:Application…”
  2. Build the solution
  3. Change it back to “<local:ID2Converter…”
  4. Voila!

In case you’re wondering, my xaml.vb file looks like this:

Imports System.Globalization

Public Class ID2Converter
 Implements IValueConverter

 Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
 ' blah blah blah
 End Function

 Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
 ' blah blah blah
 End Function
End Class

Public Class MyClass
' blah blah blah
End Class

So, you can put the IValueConverter in the same xaml.vb as the class using it. No need to declare namespace etc 🙂

Advertisements