We're going to discuss about Automatic Type converters in XAML.
Whenever you make some control in XAML you set its properties. For example in following screen shot we are making a button in XAML and setting its properties like:
- Background Color etc , you are shown a list of given option through Intellisense like below:
So you have limited options as shown in above screenshot. you've to select 1 position from 4 given options . These options are infect enums.
have you ever noticed that when you type in for setting the properties like ,
Now I'm going to show you the alternate way to set properties using C# syntax. To make a button from C# write following code in Page Load Event in program.
When you make a control from C# code. You've to set all of its properties in code. In this case we've set its
- Background properties
You selected the background color and Horizontal Alignment from a strongly typed enumeration for the button. So the question is ! How these properties are mapped to strongly typed enumeration, when you type a string which is "left" in the case of alignment property and "Red" in case of color selection.
Answer is ! XAML parser does this job.
XAML parser convert string value into a strongly typed version of that value. So when you set the properties like < horizontalAllignment = "Left" > , the string "Left" will be mapped to the strongly typed enum by the XAML parser.