17

From what I've been told, I need to create an IValueConverter to do my custom formatting. The problem is my formatting is one-way, there is no legitmate ConvertBack implementation.

So, how do I handle one-way IValueConverters. (If it helps, this is for a read-only control.)

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Jonathan Allen
  • 68,373
  • 70
  • 259
  • 447

1 Answers1

21

All the examples from Microsoft simply throw a NotSupportedException or a NotImplementedException (the former makes more sense) from the ConvertBack method.

As you say, if the converter is one-way then chances are you'll be using it on a read-only control like TextBlock, so the ConvertBack method won't be getting called anyway.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Matt Hamilton
  • 200,371
  • 61
  • 386
  • 320