Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
86 CHAPTER 3: Extensible Application Markup Language (Xaml) This literally creates an instance of the converter object and then sticks it into a dictionary using the string key "ColorConvert". Now before the closing Grid tag, you can add a TextBox to capture user input and a Rectangle element to show the color. Notice that the rectangle's fill property is bound to the text property of the text box and passes through the value converter to turn it into a solid brush: <TextBox Width="100" Height="30" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" x:Name="Text"/> <Rectangle Fill="{Binding ElementName=Text,Path=Text, Converter={StaticResource ColorConvert}}" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="10" Width="50" Height="50"/> Value converters are run through the designer. You can set the text property on the text box to "Red" or "Green" and see the rectangle change