Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 图像组合框XAML在运行时未正确显示_C#_Wpf_Xaml_Combobox - Fatal编程技术网

C# 图像组合框XAML在运行时未正确显示

C# 图像组合框XAML在运行时未正确显示,c#,wpf,xaml,combobox,C#,Wpf,Xaml,Combobox,我试图实现一个只有图像的组合框。图像不需要是动态的。我现在是这样做的: <ComboBox HorizontalAlignment="Center" x:Name="diceDot" Canvas.Left="244" Canvas.Top="10" Height="20" Width="40"> <ComboBoxItem> <Image Stretch="Fill" Sour

我试图实现一个只有图像的组合框。图像不需要是动态的。我现在是这样做的:

<ComboBox HorizontalAlignment="Center" x:Name="diceDot" Canvas.Left="244" Canvas.Top="10" Height="20" Width="40">
                    <ComboBoxItem>
                        <Image Stretch="Fill" Source="Resources/dice1.png" Height="20" Width="20"></Image>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <Image Stretch="Fill" Source="Resources/dice2.png" Height="20" Width="20"></Image>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <Image Stretch="Fill" Source="Resources/dice3.png" Height="20" Width="20"></Image>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <Image Stretch="Fill" Source="Resources/dice4.png" Height="20" Width="20"></Image>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <Image Stretch="Fill" Source="Resources/dice5.png" Height="20" Width="20"></Image>
                    </ComboBoxItem>
                    <ComboBoxItem>
                        <Image Stretch="Fill" Source="Resources/dice6.png" Height="20" Width="20"></Image>
                    </ComboBoxItem>
                </ComboBox>
已编辑:添加了错误消息


问题解决-将生成操作更改为“资源”并重建解决方案似乎可以解决问题。问题解决-将生成操作更改为“资源”并重建解决方案似乎可以解决问题。

转到图像的VS属性选项卡,他们选择了什么“生成操作”?这些引用必须是“内容”才能起作用。我以为它应该是资源或嵌入资源。不过,我已切换到内容,但在运行时它仍然不会显示我的图像。请在输出窗口中查找错误。“听起来图像的路径是错误的。”GazTheDestroyer说,“是的。输出状态是指向图像的路径错误。@almulo Ahhh。构建操作需要是“资源”而不是“内容”。
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll
A first chance exception of type 'System.IO.DirectoryNotFoundException' occurred in mscorlib.dll