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.
已解决问题-将构建操作更改为“资源”并重新构建解决方案似乎可以解决问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.