Powered by MSDN

US - English
NEW! Silverlight 5 is available Learn More

Error 2203 when assigning Silverlight collections RSS

1 reply

Last post Dec 20, 2007 03:45 AM by Yi-Lun Luo - MSFT

(0)
  • sompost

    sompost

    Member

    16 Points

    5 Posts

    Error 2203 when assigning Silverlight collections

    Dec 18, 2007 09:05 AM | LINK

    I have found a few instances (there might be more) where assigning a run-time created collection object (e.g. a GradientStopCollection) to the corresponding property (e.g. GradientStops) invariably causes an error 2203. Note that the Silverlight reference explicitely permits such assignments. Here's a minimal example:

    var plugin=canvas.getHost();
    var lgb=plugin.content.createFromXaml("<LinearGradientBrush/>");
    lgb.GradientStops=plugin.content.createFromXaml("<GradientStopCollection/>"); //ERROR 2203
    lgb.GradientStops.Add(plugin.content.createFromXaml("<GradientStop Color='Red' Offset='0.0'/>")); //OK

    Likewise with PathGeometry's Figures property. Assigning a PathFigureCollection causes error 2203. This is particularly absurd as the Figures property is initially actually null (i.e. you cannot append anything to it).

    var pg=plugin.content.createFromXaml("<PathGeometry/>");
    pg.Figures=plugin.content.createFromXaml("<PathFigureCollection/>"); //ERROR 2203
    pg.Figures.Add(plugin.content.createFromXaml("<PathFigure/>")); //ERROR Figures is null

    Unless I'm doing something really dumb here (which is thoroughly possible), it's either a bug in Silverlight or in the documentation.

    Any ideas? Thanks!

    JavaScript error 2203 bug

  • Yi-Lun Luo - MSFT

    Yi-Lun Luo -...

    All-Star

    25149 Points

    2759 Posts

    Microsoft

    Re: Error 2203 when assigning Silverlight collections

    Dec 20, 2007 03:45 AM | LINK

    Hello, for GradientBrush, you don’t need to specify a GradientStopCollection. It has been already created for you. You can directly add children. For PathGeometry, you can use createFromXaml("<PathGeometry><PathFigureCollection/ ></PathGeometry>"). This won’t cause an error. Looks like there’re some problems with JavaScript here. In managed code, if you use:

     

    brush.GradientStops = new GradientStopCollection();

    pg.Figures = new PathFigureCollection();

     

    Or even:

    GradientStopCollection collection = (GradientStopCollection)XamlReader.Load("<GradientStopCollection/>");

    brush.GradientStops = collection;

     

    It won’t cause any errors.

     

    shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.