【问题标题】:Windows Phone 7 buttons with images带有图像的 Windows Phone 7 按钮
【发布时间】:2012-02-29 10:21:11
【问题描述】:

如何以编程方式创建带有图像的按钮。我想将带有图像的按钮存储在内存中,这些图像代表纸牌游戏中所有可能的纸牌。然后,当我向玩家展示发牌时,我可以从所有可能的牌中选择正确的牌。

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!)
}

我走对了吗?

提前致谢

【问题讨论】:

    标签: c# image button windows-phone-7


    【解决方案1】:

    您可以使用 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;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多