字典<字符串,image>, WP8

本文关键字:WP8 image 字典 字符串 | 更新日期: 2023-09-27 17:49:42

我正在尝试为Windows Phone 8创建一个键/值为字符串/图像的字典。

我知道字典是如何工作的,但是我不确定我要用哪种类型的字典。

基本上,我要创建26个图像,每个字母一个,所以苹果对应一个苹果的图像。

我对如何在WP8上做到这一点感到困惑,所以在正确的方向上的任何指导将不胜感激

更新:谢谢你的回答。我肯定还是做错了什么。例如:

    //Set up the dictionary of AlphaImages objects. 
    if (AlphaImages == null)
    {
        AlphaImages = new Dictionary<string, BitmapImage>();
        AlphaImages.Add("Apple", new BitmapImage(@"Apple.jpg"));
    }

它声称我使用了无效的BitmapImage参数。在这个线程之后,用户使用以下代码采用不同的方法:

Dictionary<string, Bitmap> lookup = new Dictionary<string, Bitmap>();
lookup.Add("A", new Bitmap(@"C:'08'letters'1'a1.bmp", true));

,我不能让它工作,因为编译器吐出同样的错误。

我做错了什么?

字典<字符串,image>, WP8

尝试:

AlphaImages。添加("Apple",新的BitmapImage(新的Uri("Apple.jpg", UriKind.Relative)));

确保图像设置为内容的构建动作。

Air-coded。:)

您要找的是BitmapImage类。