I am new to WPF. I just don't understand why there is a need for TypeConverters and IValueConverter in WPF. The purpose of both objects is to convert a value to specific type; but why both?
Thanks in advance.
IValueConverter is used only in data-binding scenarios. It allows you to format values before they are displayed in the UI or to parse values from UI controls so that they can be stored in the binding source. an example would be to convert an IsDirty flag to an "*" in the UI or a Color instance to a Brush instance. from my own experience i've used IValueConverter just for formatting purposes (that is, only implementing the Convert method).
A TypeConverter derived class is mostly used to convert to/from string values. this can be used for setting a property of a custom type in XAML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With