0

I'm using Spark with WPF. This works fine and I'm able to format a template and pull in scalar properties from a custom DTO (my model). I'm having difficulty getting for loops to work though. From looking at the Spark documentation, I should be able to do this but I get a spark exception:

Dynamic view compilation failed.

c:\Users\Echilon\AppData\Local\Temp\tmp4490.tmp(73,73): error CS0103: The name 'Sections' does not exist in the current context

The following code works fine in the template to pull the Name property from the model: <h1>${Name}</h1> but the for loop generates the exception:

<for each="var sect in Sections">
    ${#sect.Name}
    <!-- HTML for each element omitted -->
</for>
zero323
  • 322,348
  • 103
  • 959
  • 935
Echilon
  • 10,064
  • 33
  • 131
  • 217

1 Answers1

0

I needed to import the collections namespace as well as the namespace containing the type of objects in my IList:

<use namespace="System.Collections.Generic"/>
<use namespace="System.Web.Mvc"/>
<use namespace="MyOtherAssembly"/>
<viewdata Sections="IList[[ISection]]"/>
Echilon
  • 10,064
  • 33
  • 131
  • 217
  • your basic framework namespaces `System.*` and your common user namespaces should be declared in the _global.spark, the spark config section in your Web.config, or added to `SparkSettings` when constructing a `SparkViewEngine` so you don't have to repeat them in every view file – Dave Thieben Jan 02 '13 at 18:56