c# - Image ComboBox XAML 在运行时无法正确显示

标签 c# wpf xaml combobox

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

<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>

但是,图像在运行时没有出现。它确实在设计过程中完美地呈现了预期的结果。我不希望包含图像的文件夹与我的可执行文件一起出现。

错误:

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

已编辑:添加了错误消息

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

最佳答案

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

关于c# - Image ComboBox XAML 在运行时无法正确显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31671839/

相关文章:

c# - 返回null时如何递归选择AdornedElement的父级

c# - 如何在C#中动态改变复选框的颜色

c# - 限制 2 个单独列表的组合计数 - C#

c# - 开源 .NET 桌面 UI 框架

c# - 将脚本标签放入div并执行

c# - 在 Windows 窗体中单击“确定”按钮时如何使焦点回到窗体?

c# - WPF AppDomain UnhandledException 处理程序超时

c# - WPF 。 NET 3.5 C# 字段已声明/具有相同名称的成员?

wpf - DatePicker 内的自定义 WPF 日历

wpf - 隐式样式不适用于自定义控件