Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating a property of type ObservableCollection in XAML with static resources
    text
    copied!<p>I have created a class that contains a property of type ObservableCollection. I am trying to create an instance of the class in XAML and fill this property with members. I keep getting an exception that class T can not be converted to ObservableCollection, but this exception only occurs when I am trying to populate the list with elements that were declared as static resources.</p> <p>Anybody has an idea why?</p> <p>The code is as follows:</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mseg="clr-namespace:SegApp.Model.DataEntities.Segments;assembly=SegApp.Model.Silverlight"&gt; &lt;mseg:Dot xKey="d1"/&gt; &lt;mseg:Dot xKey="d2"/&gt; &lt;mseg:Dot xKey="d3"/&gt; &lt;mseg:Dot xKey="d4"/&gt; &lt;mseg:Segment xKey="seg1"&gt; &lt;mseg:Segment.Dots&gt; &lt;StaticResource ResourceKey="d1"/&gt; &lt;StaticResource ResourceKey="d2"/&gt; &lt;StaticResource ResourceKey="d3"/&gt; &lt;StaticResource ResourceKey="d4"/&gt; &lt;/mseg:Segment.Dots&gt; &lt;/mseg:Segment&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>The Class definition is:</p> <pre><code>public class Segment : Part { public ObservableCollection&lt;Dot&gt; Dots { get; set; } public Segment() { Dots = new ObservableCollection&lt;Dot&gt;(); } } </code></pre> <p>And the exception says: "</p> <blockquote> <p>Object of type bla.bla.bla.Dot can not be converted to type System.Collections.ObjectModel.ObservableCollection'1[bla.bla.bla.Dot]</p> </blockquote> <p>"</p> <p>Any ideas?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload