<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.silverlight.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Programming with .NET - General</title><link>http://forums.silverlight.net/forums/17.aspx</link><description>General discussions around authoring Silverlight .NET applications.</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>Re: Re: Re: Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/238794.aspx</link><pubDate>Sun, 28 Jun 2009 09:15:03 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:238794</guid><dc:creator>Thomas Claudius Huber</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/238794.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=238794</wfw:commentRss><description>&lt;p&gt;Hi there, I came across this thread while having exactly the same (still in Silverlight 3 beta&amp;nbsp;existing)&amp;nbsp;Problem. So, to clarify it here:&lt;/p&gt;
&lt;p&gt;In WPF there are two types of collections supported by XAML:&lt;br /&gt;IList and IDictionary. The first is a simple list, the second is a collection storing keyValue-Pairs. For IList the Add-Method is simply called. On IDictionary-Collections the x:Key-Attribut must be placed on elements. The value of x:Key is passed in as first parameter to the Add-Method, the Element itself as second parameter.&lt;/p&gt;
&lt;p&gt;In Silverlight, there are also two types of collections supported by XAML:&lt;br /&gt;IList and ResourceDictionary. Unfortuneately IDictionary seems not to be supported by the XAML-Prozessor of Silverlight (it&amp;#39;s a different one than WPFs :-).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Re: Re: Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68736.aspx</link><pubDate>Mon, 07 Jul 2008 08:36:38 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68736</guid><dc:creator>swildermuth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68736.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68736</wfw:commentRss><description>&lt;p&gt;I think I was in error...I don&amp;#39;t think Dictionaries specifically (or any collection with multiple Template Parameters) would be supported in XAML in any way, but creating and using these in the code behind works well.&lt;/p&gt;</description></item><item><title>Re: Re: Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68573.aspx</link><pubDate>Sun, 06 Jul 2008 13:49:25 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68573</guid><dc:creator>MichaelDAscentium</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68573.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68573</wfw:commentRss><description>&lt;p&gt;Interesting.&amp;nbsp; According to the previous post, dictionaries are possible in WPF Xaml.&amp;nbsp; So perhaps it&amp;#39;s a Silverlight shortcoming/bug.&amp;nbsp; Sigh...&lt;/p&gt;</description></item><item><title>Re: Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68538.aspx</link><pubDate>Sun, 06 Jul 2008 09:58:15 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68538</guid><dc:creator>swildermuth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68538.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68538</wfw:commentRss><description>&lt;p&gt;There are two issues here.&amp;nbsp; Dictionaries don&amp;#39;t have a common collection (where this syntax would help) because they are two related collections Keys and Values.&amp;nbsp; There is no good way to describe this in XAML.&amp;nbsp; If I change the collection to a List&amp;lt;&amp;gt;, the XAML works:&lt;/p&gt;
&lt;p&gt;public interface IResource&lt;br /&gt;{}&lt;/p&gt;
&lt;p&gt;public class NamedResourceCollection : List&amp;lt;IResource&amp;gt;&lt;br /&gt;{}&lt;/p&gt;
&lt;p&gt;public class TestResource : IResource&lt;br /&gt;{}&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then this works:&lt;/p&gt;
&lt;p&gt;&amp;lt;Grid.Resources&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;my:NamedResourceCollection x:Key=&amp;quot;myList&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;my:TestResource /&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;/my:NamedResourceCollection&amp;gt;&lt;br /&gt;&amp;lt;/Grid.Resources&amp;gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem is that if its a dictionary, this doesn&amp;#39;t work (becaause there is no way to call &amp;quot;Add&amp;quot; method):&lt;/p&gt;
&lt;p&gt;public class NamedResourceCollection : Dictionary&amp;lt;string, IResource&amp;gt;&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Grid.Resources&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;lt;my:NamedResourceCollection x:Key=&amp;quot;myList&amp;quot;&amp;gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;my:NamedResourceCollection.Values&amp;gt;&lt;br /&gt;&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;my:TestResource /&amp;gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/my:NamedResourceCollection.Values&amp;gt;&lt;br /&gt;&lt;/strong&gt;&amp;nbsp; &amp;lt;/my:NamedResourceCollection&amp;gt;&lt;br /&gt;&amp;lt;/Grid.Resources&amp;gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Setting the Values or Keys of the Dictionary separately isn&amp;#39;t valid. And there is no way to specify what is the key and what is the value (x:Key is something completely unrelated to Keys/Values of Dictionaries).&lt;/p&gt;
&lt;p&gt;HTH&lt;/p&gt;</description></item><item><title>Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68505.aspx</link><pubDate>Sun, 06 Jul 2008 00:44:37 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68505</guid><dc:creator>MichaelDAscentium</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68505.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68505</wfw:commentRss><description>&lt;p&gt;Yes I muddled around with that a bit.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m actually using a closed Dictionary:&lt;/p&gt;
&lt;p&gt;public class NamedResourceCollection : Dictionary&amp;lt;string, IResource&amp;gt;&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;TestResource&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; : &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;IResource&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;{}&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;When I do the following:&lt;/p&gt;
&lt;p&gt;&amp;lt;Namespace:NamedResourceCollection&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;Namespace:TestResource x:Key=&amp;quot;MyKey&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/Namespace:NamedResourceCollection&amp;gt;&lt;/p&gt;
&lt;p&gt;I get the following error: NamedResourceCollection does not support TestResource as content. &lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also made NamedResourceCollection : Dictionary&amp;lt;string,TestResource&amp;gt; and got the same error...&lt;/p&gt;</description></item><item><title>Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68494.aspx</link><pubDate>Sat, 05 Jul 2008 23:16:28 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68494</guid><dc:creator>CraigN</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68494.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68494</wfw:commentRss><description>Hmm, I must be confusing it with the SortedDictionary&amp;lt;T&amp;gt;. My bad, apologies.&lt;br /&gt;</description></item><item><title>Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68493.aspx</link><pubDate>Sat, 05 Jul 2008 23:10:13 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68493</guid><dc:creator>swildermuth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68493.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68493</wfw:commentRss><description>&lt;p&gt;Here is a blog entry that talks about some work arounds that *may* work in SIlverlight:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/mikehillberg/archive/2006/10/06/LimitedGenericsSupportInXaml.aspx"&gt;http://blogs.msdn.com/mikehillberg/archive/2006/10/06/LimitedGenericsSupportInXaml.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Re: Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68492.aspx</link><pubDate>Sat, 05 Jul 2008 23:08:37 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68492</guid><dc:creator>swildermuth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68492.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68492</wfw:commentRss><description>&lt;p&gt;Craig, I think you&amp;#39;re confused.&amp;nbsp; The Generic Dictionary is definitely in SIlverlight 2.&amp;nbsp; System.Collections.Generic.Dictionary&amp;lt;&amp;gt;.&amp;nbsp; I think he was trying to determine how to instantiate them in XAML.&amp;nbsp; The problem there is that Silverlight doesn&amp;#39;t support &amp;quot;TypeArgument&amp;quot; so that you can&amp;#39;t create genertic types directly in XAML.&amp;nbsp; You&amp;#39;ll have to do it via code.&lt;/p&gt;</description></item><item><title>Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68376.aspx</link><pubDate>Sat, 05 Jul 2008 11:10:21 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68376</guid><dc:creator>CraigN</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68376.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68376</wfw:commentRss><description>&lt;p&gt;I think he wanted to know if he can use the BCL ones. No, they don&amp;#39;t exist under Silverlight 2 beta 2. Shaun is suggesting you write your own. I&amp;#39;d love to know why such a useful and well used class never made it into the Silverlight BCL.&lt;/p&gt;&lt;p&gt;If I remember correctly, an alternative lives under the System.ServiceModel namespace named something completely different, which screws up the idea of sharing code between server and client.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68365.aspx</link><pubDate>Sat, 05 Jul 2008 08:55:14 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68365</guid><dc:creator>swildermuth</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68365.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68365</wfw:commentRss><description>&lt;p&gt;Its possible, but I don&amp;#39;t have an example on me. There is a good example in the Sells/Griffiths WPF book though.&lt;/p&gt;</description></item><item><title>Dictionaries in Xaml?</title><link>http://forums.silverlight.net/forums/thread/68349.aspx</link><pubDate>Sat, 05 Jul 2008 03:11:12 GMT</pubDate><guid isPermaLink="false">d0d632c8-a6f7-4f68-b0ce-26aaafd62132:68349</guid><dc:creator>MichaelDAscentium</dc:creator><slash:comments>0</slash:comments><comments>http://forums.silverlight.net/forums/thread/68349.aspx</comments><wfw:commentRss>http://forums.silverlight.net/forums/commentrss.aspx?SectionID=17&amp;PostID=68349</wfw:commentRss><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Does anyone know if it&amp;#39;s possible to create Dictionaries in Xaml?&amp;nbsp; I have an object named &amp;quot;NamedResources&amp;quot; that inherits from Dictionary&amp;lt;string,IResource&amp;gt; and I&amp;#39;d like to define a couple items in Xaml.&amp;nbsp; So far I&amp;#39;ve had no luck doing this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Any guidance/advice would be appreciated! :)&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;</description></item></channel></rss>