Note that there are some explanatory texts on larger screens.

plurals
  1. POException thrown when resources declaration order changed
    primarykey
    data
    text
    <p>I get exception when declare resources in this order:</p> <pre><code>&lt;Window.Resources&gt; &lt;sys:Object x:Key="resourceA"&gt;&lt;/sys:Object&gt; &lt;x:Array x:Key="resourceB" Type="sys:String"&gt; &lt;sys:String&gt;foo&lt;/sys:String&gt; &lt;/x:Array&gt; &lt;/Window.Resources&gt; </code></pre> <p>and when declare this way, all works:</p> <pre><code>&lt;Window.Resources&gt; &lt;x:Array x:Key="resourceB" Type="sys:String"&gt; &lt;sys:String&gt;foo&lt;/sys:String&gt; &lt;/x:Array&gt; &lt;sys:Object x:Key="resourceA"&gt;&lt;/sys:Object&gt; &lt;/Window.Resources&gt; </code></pre> <p>The Exception thrown is:</p> <blockquote> <p>Cannot convert the value in attribute 'ItemsSource' to object of type 'System.Collections.IEnumerable'. 'System.Windows.Markup.ArrayExtension' is not a valid value for property 'ItemsSource'. Error at object 'System.Windows.Controls.ComboBox' in markup file 'WpfResourcesBug;component/window1.xaml' Line 18 Position 37.</p> </blockquote> <p>Full code:</p> <pre><code>&lt;Window x:Class="WpfResourcesBug.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" Title="Window1" Height="300" Width="300"&gt; &lt;Window.Resources&gt; &lt;sys:Object x:Key="resourceA"&gt;&lt;/sys:Object&gt; &lt;x:Array x:Key="resourceB" Type="sys:String"&gt; &lt;sys:String&gt;foo&lt;/sys:String&gt; &lt;/x:Array&gt; &lt;/Window.Resources&gt; &lt;StackPanel&gt; &lt;ComboBox SelectedIndex="0" ItemsSource="{StaticResource resourceB}" /&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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