質問するログイン新規登録

回答編集履歴

1

見直しキャンペーン中

2023/07/28 13:44

投稿

TN8001
TN8001

スコア10166

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