回答編集履歴
1
見直しキャンペーン中
test
CHANGED
@@ -1,109 +1,55 @@
|
|
1
1
|
RXはあまりわかっていませんが、更新前に選択してるような状態なんじゃないでしょうか?
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
miyagさんの意図通りかちょっと自信がありませんが、このようにしたところ選択は維持されました。
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
```
|
5
|
+
```cs
|
10
|
-
|
11
6
|
using Reactive.Bindings;
|
12
|
-
|
13
7
|
using Reactive.Bindings.Extensions;
|
14
|
-
|
15
8
|
using System;
|
16
|
-
|
17
9
|
using System.ComponentModel;
|
18
|
-
|
19
10
|
using System.Diagnostics;
|
20
|
-
|
21
11
|
using System.Reactive.Disposables;
|
22
|
-
|
23
12
|
using System.Reactive.Linq;
|
24
|
-
|
25
13
|
using System.Threading;
|
26
14
|
|
27
|
-
|
28
|
-
|
29
15
|
namespace Questions328623
|
30
|
-
|
31
16
|
{
|
32
|
-
|
33
17
|
public class MainWindowViewModel : INotifyPropertyChanged
|
34
|
-
|
35
18
|
{
|
36
|
-
|
37
19
|
public event PropertyChangedEventHandler PropertyChanged;
|
38
|
-
|
39
20
|
private CompositeDisposable Disposable { get; } = new CompositeDisposable();
|
40
21
|
|
41
|
-
|
42
|
-
|
43
22
|
public ReactiveCollection<string> ListData { get; } = new ReactiveCollection<string>();
|
44
|
-
|
45
|
-
|
46
23
|
|
47
24
|
public ReactiveProperty<string> SelectedNo { get; } = new ReactiveProperty<string>();
|
48
25
|
|
49
26
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
27
|
public MainWindowViewModel()
|
54
|
-
|
55
28
|
{
|
56
|
-
|
57
29
|
//SelectedNo.Subscribe(_ => { });
|
58
30
|
|
59
|
-
|
60
|
-
|
61
31
|
Observable.Timer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(10))
|
62
|
-
|
63
32
|
.ObserveOn(SynchronizationContext.Current)
|
64
|
-
|
65
33
|
.Subscribe(_ =>
|
66
|
-
|
67
34
|
{
|
68
|
-
|
69
35
|
var selectedNo = SelectedNo.Value;
|
70
|
-
|
71
36
|
ListDataUpdate();
|
72
|
-
|
73
37
|
SelectedNo.Value = selectedNo;
|
74
38
|
|
75
|
-
|
76
|
-
|
77
39
|
Debug.WriteLine(SelectedNo);
|
78
|
-
|
79
40
|
}).AddTo(Disposable);
|
80
|
-
|
81
41
|
}
|
82
42
|
|
83
|
-
|
84
|
-
|
85
43
|
private Random random = new Random();
|
86
|
-
|
87
44
|
private void ListDataUpdate()
|
88
|
-
|
89
45
|
{
|
90
|
-
|
91
46
|
ListData.Clear();
|
92
|
-
|
93
47
|
var max = random.Next(50);
|
94
|
-
|
95
48
|
for (var i = 1; i <= max; i++)
|
96
|
-
|
97
49
|
{
|
98
|
-
|
99
50
|
ListData.Add(i.ToString());
|
100
|
-
|
101
51
|
}
|
102
|
-
|
103
52
|
}
|
104
|
-
|
105
53
|
}
|
106
|
-
|
107
54
|
}
|
108
|
-
|
109
55
|
```
|