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

回答編集履歴

1

見直しキャンペーン中

2023/07/26 15:14

投稿

TN8001
TN8001

スコア10180

answer CHANGED
@@ -1,55 +1,55 @@
1
- RXはあまりわかっていませんが、更新前に選択してるような状態なんじゃないでしょうか?
2
-
3
- miyagさんの意図通りかちょっと自信がありませんが、このようにしたところ選択は維持されました。
4
-
5
- ```C#
6
- using Reactive.Bindings;
7
- using Reactive.Bindings.Extensions;
8
- using System;
9
- using System.ComponentModel;
10
- using System.Diagnostics;
11
- using System.Reactive.Disposables;
12
- using System.Reactive.Linq;
13
- using System.Threading;
14
-
15
- namespace Questions328623
16
- {
17
- public class MainWindowViewModel : INotifyPropertyChanged
18
- {
19
- public event PropertyChangedEventHandler PropertyChanged;
20
- private CompositeDisposable Disposable { get; } = new CompositeDisposable();
21
-
22
- public ReactiveCollection<string> ListData { get; } = new ReactiveCollection<string>();
23
-
24
- public ReactiveProperty<string> SelectedNo { get; } = new ReactiveProperty<string>();
25
-
26
-
27
- public MainWindowViewModel()
28
- {
29
- //SelectedNo.Subscribe(_ => { });
30
-
31
- Observable.Timer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(10))
32
- .ObserveOn(SynchronizationContext.Current)
33
- .Subscribe(_ =>
34
- {
35
- var selectedNo = SelectedNo.Value;
36
- ListDataUpdate();
37
- SelectedNo.Value = selectedNo;
38
-
39
- Debug.WriteLine(SelectedNo);
40
- }).AddTo(Disposable);
41
- }
42
-
43
- private Random random = new Random();
44
- private void ListDataUpdate()
45
- {
46
- ListData.Clear();
47
- var max = random.Next(50);
48
- for (var i = 1; i <= max; i++)
49
- {
50
- ListData.Add(i.ToString());
51
- }
52
- }
53
- }
54
- }
1
+ RXはあまりわかっていませんが、更新前に選択してるような状態なんじゃないでしょうか?
2
+
3
+ miyagさんの意図通りかちょっと自信がありませんが、このようにしたところ選択は維持されました。
4
+
5
+ ```cs
6
+ using Reactive.Bindings;
7
+ using Reactive.Bindings.Extensions;
8
+ using System;
9
+ using System.ComponentModel;
10
+ using System.Diagnostics;
11
+ using System.Reactive.Disposables;
12
+ using System.Reactive.Linq;
13
+ using System.Threading;
14
+
15
+ namespace Questions328623
16
+ {
17
+ public class MainWindowViewModel : INotifyPropertyChanged
18
+ {
19
+ public event PropertyChangedEventHandler PropertyChanged;
20
+ private CompositeDisposable Disposable { get; } = new CompositeDisposable();
21
+
22
+ public ReactiveCollection<string> ListData { get; } = new ReactiveCollection<string>();
23
+
24
+ public ReactiveProperty<string> SelectedNo { get; } = new ReactiveProperty<string>();
25
+
26
+
27
+ public MainWindowViewModel()
28
+ {
29
+ //SelectedNo.Subscribe(_ => { });
30
+
31
+ Observable.Timer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(10))
32
+ .ObserveOn(SynchronizationContext.Current)
33
+ .Subscribe(_ =>
34
+ {
35
+ var selectedNo = SelectedNo.Value;
36
+ ListDataUpdate();
37
+ SelectedNo.Value = selectedNo;
38
+
39
+ Debug.WriteLine(SelectedNo);
40
+ }).AddTo(Disposable);
41
+ }
42
+
43
+ private Random random = new Random();
44
+ private void ListDataUpdate()
45
+ {
46
+ ListData.Clear();
47
+ var max = random.Next(50);
48
+ for (var i = 1; i <= max; i++)
49
+ {
50
+ ListData.Add(i.ToString());
51
+ }
52
+ }
53
+ }
54
+ }
55
55
  ```