O'Reilly logo

Windows Application Development Cookbook by Marcin Jamro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using value converters with parameters

As you saw in the previous recipe, a value converter allows you to convert one value into another, with the same or different type. However, such a solution also makes it possible to take into account a parameter during a conversion. Thus, you can prepare one value converter and parameterize it directly in the XAML code to limit code duplication and improve its quality. You will learn how to do this in this recipe.

As an example, you will create a page with a button and a text block. After consecutive clicks on the button, the color of the text block should be changed to green, red, green, and so on. Of course, the example will use the data binding mechanism with a value converter. This converter takes a parameter ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required