Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - Compilation error: Tags of type 'PropertyArrayStart' are not supported in template sections

Ordinarily I wouldn't just post an error message on SO, but after a Google search only found one hit, I thought I'd at least open the floor for this error here on SO.

I have a custom control called Sparkline with a dependency property called Values of type unit[]. Here's an example where I use it in a DataTemplate:

<DataTemplate DataType="{x:Type Activity:ActivityHistory}">     <Controls:Sparkline Grid.Column="1" Values="{Binding Path=Values}" /> </DataTemplate> 

This code doesn't compile. I receive the error message:

Tags of type 'PropertyArrayStart' are not supported in template sections.

The line/column numbers indicate the start of the Values attribute.

This has really thrown me. Searching on Google returned one result where John_C hit exactly the same issue. Unfortunately, his solution involved moving the control to a separate assembly. Well, mine's already in a separate assembly. My guess is that something else is at play.

I've never heard of PropertyArrayStart. Searching for that only return a few pages related to XAML serialisation. Interesting stuff, but not much help.

Thinking about it, I can't think of any dependency properties in the framework that have array types. Is this allowed?

I also tried using a nested element instead of a markup extension for the Binding.

<DataTemplate DataType="{x:Type Activity:ActivityHistory}">     <Controls:Sparkline Grid.Column="1">         <Controls:Sparkline.Values>             <Binding Path="Values"/>         </Controls:Sparkline.Values>     </Controls:Sparkline> </DataTemplate> 

...still no luck.

Any ideas welcomed!

like image 366
Drew Noakes Avatar asked May 29 '09 15:05

Drew Noakes


1 Answers

It's been an eventful 27 minutes... :)

Changing the dependency property's type from unit[] to IList<unit> solved the problem. Best of all, it didn't requite many code changes as the array already implements that interface.

I'm not sure whether dispatching to the array via the interface (callvirt) is slower. My guess is yes.

The original error message hints that there's something going on here that I don't quite understand. I'll accept any answer that explains it properly.

like image 98
Drew Noakes Avatar answered Oct 21 '22 05:10

Drew Noakes