Windows phone 8 如何在wp8应用程序中将图像声明为本地数据库中的列

Windows phone 8 如何在wp8应用程序中将图像声明为本地数据库中的列,windows-phone-8,linq-to-sql,linq-to-entities,Windows Phone 8,Linq To Sql,Linq To Entities,我必须将用户选择的图像存储在本地数据库中。当我尝试将列创建为Image时,它会显示任何类似Image的数据类型。仅显示System.Windows.Controls.Image private Image _imageData; [Column(CanBeNull = true)] public Image ImageData { get { return _imageData; } set {

我必须将用户选择的图像存储在本地数据库中。当我尝试将列创建为Image时,它会显示任何类似Image的数据类型。仅显示System.Windows.Controls.Image

    private Image _imageData;
    [Column(CanBeNull = true)]
    public Image ImageData
    {
        get { return _imageData; }
        set
        {
            if (_imageData != value)
            {
                NotifyPropertyChanging("ImageData");
                _imageData = value;
                NotifyPropertyChanging("ImageData");
            }
        }
    }
这是我试图在其中一个表中创建的列。如何将映像声明为数据类型


谢谢。

不确定我是否理解正确,但您是否尝试过存储Uri而不是图像

private Uri _imageUri;
[Column(CanBeNull = true)]
public Uri ImageUri
{
    get { return _imageUri; }
    set
    {
        if (_imageUri!= value)
        {
            NotifyPropertyChanging("ImageUri");
            _imageUri= value;
            NotifyPropertyChanged("ImageUri");

            NotifyPropertyChanged("ImageData");
        }
    }
}

public Image ImageData
{
    get { return new BitmapImage(ImageUri); }
}

另外,您给NotifyPropertyChange打了两次电话,好像是打字错误。

谢谢Eladar。但我必须在哪里存储实际图像?根据MSDN,“您可以使用binary(n)、varbinary(n)或image数据类型将BLOB数据直接存储在本地数据库中”。但由于无法找到数据类型,您可以将图像存储在单独的存储器中。如果要存储BLOB,请使用,它将映射到BLOB或IMAGE。正如我所知,BLOB大小是有限制的,我认为最好使用隔离存储。