回答編集履歴

1

見直しキャンペーン中

2023/07/28 13:44

投稿

TN8001
TN8001

スコア9326

test CHANGED
@@ -1,73 +1,37 @@
1
1
  `ReactiveProperty`は`Value`の値が変わったときに、`PropertyChanged`イベントを発行する仕組みです。
2
-
3
2
  `INotifyPropertyChanged`の実装で、プロパティのセッターであれこれする面倒を隠ぺいしてくれます。
4
3
 
5
-
6
-
7
4
  なので`ReactiveProperty`自体を、丸ごと入れ替えては意味がありません。
8
-
9
5
  `Value`に入れてください。
10
-
11
-
12
6
 
13
7
  こういうミスが起きないよう、`ReactiveProperty`はゲッターのみにするのをお勧めします。
14
8
 
15
-
16
-
17
- ```C#
9
+ ```cs
18
-
19
10
  using Prism.Mvvm;
20
-
21
11
  using Reactive.Bindings;
22
-
23
12
  using System;
24
-
25
13
  using System.Windows;
26
-
27
14
  using System.Windows.Media.Imaging;
28
15
 
29
-
30
-
31
16
  namespace Questions349227
32
-
33
17
  {
34
-
35
18
  public class MainWindowViewModel : BindableBase
36
-
37
19
  {
38
-
39
20
  public ReactiveProperty<BitmapImage> Bitmap { get; } = new ReactiveProperty<BitmapImage>();
40
-
41
21
  public ReactiveCommand ImageDispLayButton { get; } = new ReactiveCommand();
42
22
 
43
-
44
-
45
23
  public MainWindowViewModel()
46
-
47
24
  {
48
-
49
25
  ImageDispLayButton.Subscribe(ImageDispLayButtonExe);
50
-
51
26
  }
52
27
 
53
-
54
-
55
28
  private void ImageDispLayButtonExe()
56
-
57
29
  {
58
-
59
30
  BitmapImage image1 = new BitmapImage(new Uri(@"https://teratail-v2.storage.googleapis.com/uploads/avatars/u19/191969/efjnfT0D_thumbnail.jpg"));
60
-
61
31
  Bitmap.Value = image1;
62
32
 
63
-
64
-
65
33
  MessageBox.Show("画像表示");
66
-
67
34
  }
68
-
69
35
  }
70
-
71
36
  }
72
-
73
37
  ```