C# 带图像的Windows Phone 7按钮
如何以编程方式创建带有图像的按钮。我想在内存中存储包含代表纸牌游戏中所有可能牌的图像的按钮。然后,当我向玩家显示已发牌时,我可以从所有可能的牌中选择正确的牌C# 带图像的Windows Phone 7按钮,c#,image,button,windows-phone-7,C#,Image,Button,Windows Phone 7,如何以编程方式创建带有图像的按钮。我想在内存中存储包含代表纸牌游戏中所有可能牌的图像的按钮。然后,当我向玩家显示已发牌时,我可以从所有可能的牌中选择正确的牌 Button[] cardButtons = new Button[52]; for(int i = 0; i < 52; i++) { cardButtons[i] = new Button(); cardButtons[i] = new Image(.... I dont know what goes here,
Button[] cardButtons = new Button[52];
for(int i = 0; i < 52; i++)
{
cardButtons[i] = new Button();
cardButtons[i] = new Image(.... I dont know what goes here, or if any of this is correct!)
}
按钮[]卡片按钮=新按钮[52];
对于(int i=0;i<52;i++)
{
cardButtons[i]=新按钮();
cardButtons[i]=新图像(……我不知道这里是什么,或者这些是否正确!)
}
我走对了吗
提前感谢您可以使用Button类的.Content属性
Button[] cardButtons = new Button[52];
for(int i = 0; i < 52; i++)
{
Uri uri = new Uri("/images/someImage.png", UriKind.Relative);
BitmapImage imgSource = new BitmapImage(uri);
Image image = new Image();
image.Source = imgSource;
cardButtons [i] = new Button();
cardButtons[i].Content = image;
}
按钮[]卡片按钮=新按钮[52];
对于(int i=0;i<52;i++)
{
Uri=newURI(“/images/someImage.png”,UriKind.Relative);
BitmapImage imgSource=新的BitmapImage(uri);
图像=新图像();
image.Source=imgSource;
cardButtons[i]=新按钮();
卡片按钮[i]。内容=图像;
}