Binding with a value converter
In the previous recipes, you learned how to adjust the user interface based on the values of properties defined within the view model class. However, you could ask yourself these simple questions: What should I do to show or hide some elements using the data binding mechanism?
Do I need to define a separate property of the Visibility type for each element with such a feature? Of course, you could solve this problem in the mentioned way. However, there is a much better approach available if you use value converters. They allow you to convert a particular value into another. For instance, you can define a value converter that could convert a Boolean value into the Visibility
enumeration value. You will learn how to do this in the current recipe.
As an example, you will create a simple toggle mechanism that will hide or show the text block after you click on the button. Of course, the data binding mechanism together with the value converter will be used for this...