回答編集履歴
2
コード修正
test
CHANGED
@@ -60,18 +60,18 @@
|
|
60
60
|
|
61
61
|
{
|
62
62
|
|
63
|
-
XValues = ModelInstance.Positions.Select(positions => positions.Select(position => (int)position.X).ToList()).ToRea
|
63
|
+
XValues = ModelInstance.Positions.Select(positions => positions.Select(position => (int)position.X).ToList()).ToReactiveProperty().AddTo(_disposable);
|
64
64
|
|
65
|
-
YValues = ModelInstance.Positions.Select(positions => positions.Select(position => (int)position.Y).ToList()).ToRea
|
65
|
+
YValues = ModelInstance.Positions.Select(positions => positions.Select(position => (int)position.Y).ToList()).ToReactiveProperty().AddTo(_disposable);
|
66
66
|
|
67
67
|
}
|
68
68
|
|
69
69
|
|
70
70
|
|
71
|
-
public Rea
|
71
|
+
public ReactiveProperty<List<int>> XValues { get; }
|
72
72
|
|
73
73
|
|
74
74
|
|
75
|
-
public Rea
|
75
|
+
public ReactiveProperty<List<int>> YValues { get; }
|
76
76
|
|
77
77
|
```
|
1
別の方法を追記
test
CHANGED
@@ -45,3 +45,33 @@
|
|
45
45
|
public ReadOnlyReactiveCollection<int> YValues { get; }
|
46
46
|
|
47
47
|
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
上記の方法では、`Positions`の操作(追加、移動など)に応じて,`XValues`や`YValues`も変わるようになりますが,`Positions`のリストを丸ごと変えるだけというのであれば、`Model`はそのままで、`ViewModel`を以下のように修正するのでもいいかもしれません。
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```C#
|
58
|
+
|
59
|
+
public ViewModel ()
|
60
|
+
|
61
|
+
{
|
62
|
+
|
63
|
+
XValues = ModelInstance.Positions.Select(positions => positions.Select(position => (int)position.X).ToList()).ToReadOnlyReactiveProperty().AddTo(_disposable);
|
64
|
+
|
65
|
+
YValues = ModelInstance.Positions.Select(positions => positions.Select(position => (int)position.Y).ToList()).ToReadOnlyReactiveProperty().AddTo(_disposable);
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
public ReadOnlyReactiveProperty<List<int>> XValues { get; }
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
public ReadOnlyReactiveProperty<List<int>> YValues { get; }
|
76
|
+
|
77
|
+
```
|