XAML using CLR object as property ...

Just today I discovered a feature of XAML - ability to use custom CLR object as property to my Avalon control. All you need in the XAML is to map your assembly into a namespace in XAML. This is kinda like XML serialization in CLR. Here's an example of the usage in standard XAML element[from https://longhorn.msdn.microsoft.com] -

 <Rectangle RectangleLeft="10" RectangleTop="10"
RectangleWidth="300" RectangleHeight="200">

<Rectangle.Fill> <!-- a property that takes in an object -->
<LinearGradientBrush> <!-- XAML will create this object -->
<LinearGradientBrush.GradientStops> <!-- another property -->
<GradientStopCollection>
<GradientStop Color="red" Offset="0"/>
<GradientStop Color="yellow" Offset="1" />
<GradientStop Color="blue" Offset="0.5"/>
<GradientStop Color="white" Offset="0.2"/>
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Rectangle.Fill>

</Rectangle>

The same technique is used in Avalon Animation markup as well. Finally, you can write your own Avalon control that take in CLR object as your property with XAML doing the parsing and object creation for you. This can be very useful.

This posting is provided "AS IS" with no warranties, and confers no rights.