我在网上找到了一些可以在自己的项目中使用的代码。这很简单,但是当我运行程序时,我收到一条错误消息,提示它找不到资源。
我已经尝试了很多,根本看不到错误-我通过说插入图片:添加->新文件夹(右键单击)->添加所有图像:
int[] yourHandArray = yourHand.ToInt();
int[] dealerHandArray = dealerHand.ToInt();
for (int i = 0; i < yourHandArray.Length; i++)
{
switch (i)
{
case 0: Card1.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/"+ (yourHandArray[i] + 1) + ".png")); break;
case 1: Card2.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 2: Card3.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_Cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 3: Card4.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 4: Card5.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 5: Card6.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
case 6: Card7.Source = new BitmapImage(new Uri("pack://application:,,,/View/img_cards/" + (yourHandArray[i] + 1) + ".png")); break;
}
}