0

Personを定義するクラスがあります。クラスでは、次のように定義しています。

    [XmlIgnore]
    public BitmapImage PhotoSource
        {
        get { return _PhotoSource; }
        set
            {
            _PhotoSource = value;
            NotifyPropertyChanged( "PhotoSource" );
            }
        }

追加しました:

      [XmlIgnore]

対使用

      [DataMember]

シリアル化はBitmapImageでは機能しないためです。

ただし、BitmapImageLocalやローミングを保存する必要があります。

どうすればそれを達成できますか?

ありがとう、EitanB

4

1 に答える 1

2

BitmapImageからファイルを作成し、StorageFileクラスを使用してファイルシステムに書き込みます。

    Windows.Storage.StorageFile file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(bmImage.UriSource);
    await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder);

ファイルをBitmapImageにロードし直すには:

BitmapImage bmImage;
bmImage = new BitmapImage();

bmImage.UriSource = new Uri(new Uri(
     Windows.Storage.ApplicationData.Current.LocalFolder.Path + "\\" +
     Windows.Storage.ApplicationData.Current.LocalFolder.Name), 
     "favicon.scale-100.ico");
于 2012-09-27T20:37:18.557 に答える