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