« Attached properties in Silverlight control templates | Main | We suck at news »

February 11, 2010

Attached properties in Silverlight redux

I wrote yesterday about fixing the White Screen of Death when binding to an attached property in a Silverlight control template.  The fix was to repeat the xmlns declaration for the attached property namespace on the root element of the control template.

I ran into this again today and this time inserting the xmlns declaration only gave me an exciting new error: “Exception from HRESULT: 0xC00CEE64.”

Translated from the Silverlighty, this means “Today I am not going to let you redeclare the local: XML namespace on your root element.  Instead, I require you to use a different prefix.”  Thus, instead of writing:

<Border CornerRadius="4" Background="HotPink"
        xmlns:local="clr-namespace:SilverlightFail;assembly=SilverlightFail">

as in yesterday’s example, you would have to write:

<Border CornerRadius="4" Background="HotPink"
        xmlns:fail="clr-namespace:SilverlightFail;assembly=SilverlightFail">

and adjust the property prefix accordingly.

In addition, it appears that the xmlns redeclaration has to be on the immediate parent of the element where you want to use the attached property.

I don’t know why Silverlight sometimes accepts the redeclaration and sometimes does not.  My scenario today used an attached property as the binding target rather than the binding source but the 0xC00CEE64 error occurred just from inserting the xmlns declaration, not even using it, so I don’t think it was that.  Just another mystery.

February 11, 2010 in Software | Permalink

TrackBack

TrackBack URL for this entry:
https://www.typepad.com/services/trackback/6a00d8341c5c9b53ef0128778c3ffb970c

Listed below are links to weblogs that reference Attached properties in Silverlight redux:

Comments