简体   繁体   English

图像ComboBox XAML在运行期间无法正确显示

[英]Image ComboBox XAML not displaying properly during runtime

I'm trying to achieve a combo box with only images. 我正在尝试实现仅包含图像的组合框。 The images doesn't need to be dynamic. 图像不需要是动态的。 I'm currently doing it this way: 我目前正在这样做:

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

However, the images did not appear during runtime. 但是,图像在运行时未出现。 It did render perfectly with the intended result during the design. 在设计过程中,它确实完美地呈现了预期的结果。 I do not want a folder with the images to appear together with my executable file. 我不希望包含图像的文件夹与我的可执行文件一起显示。

Error: 错误:

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

Edited: Added error messages 编辑:添加错误消息

Problem fixed - Changing the build action to "Resource" and rebuilding the solution seemed to fix the problem. 已解决问题-将构建操作更改为“资源”并重新构建解决方案似乎可以解决问题。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM