回答編集履歴
6
見直しキャンペーン中
answer
CHANGED
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
最終的な結論は当該issueを確認してください。
|
|
2
|
-
[2枚目以降のウィンドウでバリデーションエラー赤枠が残る · Issue #258 · runceel/ReactiveProperty](https://github.com/runceel/ReactiveProperty/issues/258)
|
|
3
|
-
|
|
4
|
-
対応版がリリースされました。
|
|
5
|
-
[ReactiveProperty 7.10.0 をリリースしました](https://zenn.dev/okazuki/articles/62a6c6c9d1a12baccc93#7.10.0)
|
|
6
|
-
[Getting start for WPF | ReactiveProperty documentation](https://okazuki.jp/ReactiveProperty/getting-started/wpf.html)
|
|
7
|
-
|
|
8
|
-
全部書き換えたい気分ですが^^; 経緯が分からなくなってしまうので残します。
|
|
9
|
-
が、以下は見る必要はありません。
|
|
10
|
-
|
|
11
|
-
~~はっきり言って分かってませんが、~~
|
|
12
|
-
|
|
13
|
-
~~* `ReactivePropertyMode.IgnoreInitialValidationError`を入れる~~
|
|
14
|
-
~~* `Validation.ErrorTemplate`を設定する~~
|
|
15
|
-
|
|
16
|
-
~~どちらかをしたら消えました。~~
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
~~そういう仕様(という名のバグ?)な気がします(深堀する気はありません)~~
|
|
20
|
-
~~一番手間がかからなそうな回避策はこんなんでしょうか?(バカバカしいがw~~
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
<Window.Resources>
|
|
24
|
-
<Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
|
|
25
|
-
<Style.Triggers>
|
|
26
|
-
<Trigger Property="Validation.HasError" Value="False">
|
|
27
|
-
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
|
|
28
|
-
</Trigger>
|
|
29
|
-
</Style.Triggers>
|
|
30
|
-
</Style>
|
|
31
|
-
</Window.Resources>
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
~~どこかに言及があると思いますし回避策も同じようなものだと思いますが、これといったところを見つけられませんでした^^;~~
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
最小限のコードを作って検証したところ、
|
|
39
|
-
最初の`Window`は問題ないのですが、そこからさらに`Window`を開くと赤枠が残ります。
|
|
40
|
-
|
|
41
|
-
すべて最新版を使用、.NET48・.NET5とも同様。比較相手は↓です。
|
|
42
|
-
[NuGet Gallery | CommunityToolkit.Mvvm 7.0.1](https://www.nuget.org/packages/CommunityToolkit.Mvvm/)
|
|
43
|
-
[ObservableValidator - Windows Community Toolkit | Microsoft Docs](https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/observablevalidator)
|
|
44
|
-
|
|
45
|
-
```
|
|
46
|
-
<Window
|
|
47
|
-
x:Class="Questions334418.MainWindow"
|
|
48
|
-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
49
|
-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
50
|
-
xmlns:local="clr-namespace:Questions334418"
|
|
51
|
-
Width="800"
|
|
52
|
-
Height="450">
|
|
53
|
-
<Window.DataContext>
|
|
54
|
-
<local:ViewModel />
|
|
55
|
-
</Window.DataContext>
|
|
56
|
-
<StackPanel VerticalAlignment="Center">
|
|
57
|
-
<Button Click="Button_Click" Content="open" />
|
|
58
|
-
<TextBox Text="{Binding RP_Text.Value, UpdateSourceTrigger=PropertyChanged}" />
|
|
59
|
-
<TextBox Text="{Binding OV_Text, UpdateSourceTrigger=PropertyChanged}" />
|
|
60
|
-
</StackPanel>
|
|
61
|
-
</Window>
|
|
62
|
-
```
|
|
63
|
-
```
|
|
64
|
-
using CommunityToolkit.Mvvm.ComponentModel;
|
|
65
|
-
using Reactive.Bindings;
|
|
66
|
-
using System.ComponentModel.DataAnnotations;
|
|
67
|
-
using System.Windows;
|
|
68
|
-
|
|
69
|
-
namespace Questions334418
|
|
70
|
-
{
|
|
71
|
-
public partial class MainWindow : Window
|
|
72
|
-
{
|
|
73
|
-
public MainWindow()
|
|
74
|
-
{
|
|
75
|
-
InitializeComponent();
|
|
76
|
-
|
|
77
|
-
// xamlのWindow.DataContextが残っていると上書きしようがおかしなまま。
|
|
78
|
-
//DataContext = new ViewModel();
|
|
79
|
-
|
|
80
|
-
var vm = DataContext as ViewModel;
|
|
81
|
-
vm.RP_Text.Value = "a";
|
|
82
|
-
vm.OV_Text = "a";
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private void Button_Click(object sender, RoutedEventArgs e) => new MainWindow().Show();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public class ViewModel : ObservableValidator
|
|
89
|
-
{
|
|
90
|
-
[Required(ErrorMessage = "値を入力してください。")]
|
|
91
|
-
//[StringLength(8, ErrorMessage = "8文字以内で入力してください。")]
|
|
92
|
-
public ReactiveProperty<string> RP_Text { get; }
|
|
93
|
-
|
|
94
|
-
[Required(ErrorMessage = "値を入力してください。")]
|
|
95
|
-
//[StringLength(8, ErrorMessage = "8文字以内で入力してください。")]
|
|
96
|
-
public string OV_Text { get => text; set => SetProperty(ref text, value, true); }
|
|
97
|
-
private string text;
|
|
98
|
-
|
|
99
|
-
public ViewModel() => RP_Text = new ReactiveProperty<string>().SetValidateAttribute(() => RP_Text);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
~~コードで`DataContext`を設定するという回避法はあんまりなので(DIできないし挙動が変わるというのも気持ちが悪い)、`ImmediateScheduler`を指定するのがいいのかもしれません。~~
|
|
107
|
-
~~それにより`DataContext`の設定方法によらず同じ挙動になりました。~~
|
|
108
|
-
|
|
109
|
-
~~ただしUIスレッドを複数作ってはいけない等の制限事項があります。~~
|
|
1
|
+
最終的な結論は当該issueを確認してください。
|
|
2
|
+
[2枚目以降のウィンドウでバリデーションエラー赤枠が残る · Issue #258 · runceel/ReactiveProperty](https://github.com/runceel/ReactiveProperty/issues/258)
|
|
3
|
+
|
|
4
|
+
対応版がリリースされました。
|
|
5
|
+
[ReactiveProperty 7.10.0 をリリースしました](https://zenn.dev/okazuki/articles/62a6c6c9d1a12baccc93#7.10.0)
|
|
6
|
+
[Getting start for WPF | ReactiveProperty documentation](https://okazuki.jp/ReactiveProperty/getting-started/wpf.html)
|
|
7
|
+
|
|
8
|
+
全部書き換えたい気分ですが^^; 経緯が分からなくなってしまうので残します。
|
|
9
|
+
が、以下は見る必要はありません。
|
|
10
|
+
|
|
11
|
+
~~はっきり言って分かってませんが、~~
|
|
12
|
+
|
|
13
|
+
~~* `ReactivePropertyMode.IgnoreInitialValidationError`を入れる~~
|
|
14
|
+
~~* `Validation.ErrorTemplate`を設定する~~
|
|
15
|
+
|
|
16
|
+
~~どちらかをしたら消えました。~~
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
~~そういう仕様(という名のバグ?)な気がします(深堀する気はありません)~~
|
|
20
|
+
~~一番手間がかからなそうな回避策はこんなんでしょうか?(バカバカしいがw~~
|
|
21
|
+
|
|
22
|
+
```xml
|
|
23
|
+
<Window.Resources>
|
|
24
|
+
<Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
|
|
25
|
+
<Style.Triggers>
|
|
26
|
+
<Trigger Property="Validation.HasError" Value="False">
|
|
27
|
+
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
|
|
28
|
+
</Trigger>
|
|
29
|
+
</Style.Triggers>
|
|
30
|
+
</Style>
|
|
31
|
+
</Window.Resources>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
~~どこかに言及があると思いますし回避策も同じようなものだと思いますが、これといったところを見つけられませんでした^^;~~
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
最小限のコードを作って検証したところ、ReactivePropertyが何かおかしいです。
|
|
39
|
+
最初の`Window`は問題ないのですが、そこからさらに`Window`を開くと赤枠が残ります。
|
|
40
|
+
|
|
41
|
+
すべて最新版を使用、.NET48・.NET5とも同様。比較相手は↓です。
|
|
42
|
+
[NuGet Gallery | CommunityToolkit.Mvvm 7.0.1](https://www.nuget.org/packages/CommunityToolkit.Mvvm/)
|
|
43
|
+
[ObservableValidator - Windows Community Toolkit | Microsoft Docs](https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/observablevalidator)
|
|
44
|
+
|
|
45
|
+
```xml
|
|
46
|
+
<Window
|
|
47
|
+
x:Class="Questions334418.MainWindow"
|
|
48
|
+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
49
|
+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
50
|
+
xmlns:local="clr-namespace:Questions334418"
|
|
51
|
+
Width="800"
|
|
52
|
+
Height="450">
|
|
53
|
+
<Window.DataContext>
|
|
54
|
+
<local:ViewModel />
|
|
55
|
+
</Window.DataContext>
|
|
56
|
+
<StackPanel VerticalAlignment="Center">
|
|
57
|
+
<Button Click="Button_Click" Content="open" />
|
|
58
|
+
<TextBox Text="{Binding RP_Text.Value, UpdateSourceTrigger=PropertyChanged}" />
|
|
59
|
+
<TextBox Text="{Binding OV_Text, UpdateSourceTrigger=PropertyChanged}" />
|
|
60
|
+
</StackPanel>
|
|
61
|
+
</Window>
|
|
62
|
+
```
|
|
63
|
+
```cs
|
|
64
|
+
using CommunityToolkit.Mvvm.ComponentModel;
|
|
65
|
+
using Reactive.Bindings;
|
|
66
|
+
using System.ComponentModel.DataAnnotations;
|
|
67
|
+
using System.Windows;
|
|
68
|
+
|
|
69
|
+
namespace Questions334418
|
|
70
|
+
{
|
|
71
|
+
public partial class MainWindow : Window
|
|
72
|
+
{
|
|
73
|
+
public MainWindow()
|
|
74
|
+
{
|
|
75
|
+
InitializeComponent();
|
|
76
|
+
|
|
77
|
+
// xamlのWindow.DataContextが残っていると上書きしようがおかしなまま。
|
|
78
|
+
//DataContext = new ViewModel();
|
|
79
|
+
|
|
80
|
+
var vm = DataContext as ViewModel;
|
|
81
|
+
vm.RP_Text.Value = "a";
|
|
82
|
+
vm.OV_Text = "a";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
private void Button_Click(object sender, RoutedEventArgs e) => new MainWindow().Show();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public class ViewModel : ObservableValidator
|
|
89
|
+
{
|
|
90
|
+
[Required(ErrorMessage = "値を入力してください。")]
|
|
91
|
+
//[StringLength(8, ErrorMessage = "8文字以内で入力してください。")]
|
|
92
|
+
public ReactiveProperty<string> RP_Text { get; }
|
|
93
|
+
|
|
94
|
+
[Required(ErrorMessage = "値を入力してください。")]
|
|
95
|
+
//[StringLength(8, ErrorMessage = "8文字以内で入力してください。")]
|
|
96
|
+
public string OV_Text { get => text; set => SetProperty(ref text, value, true); }
|
|
97
|
+
private string text;
|
|
98
|
+
|
|
99
|
+
public ViewModel() => RP_Text = new ReactiveProperty<string>().SetValidateAttribute(() => RP_Text);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
~~コードで`DataContext`を設定するという回避法はあんまりなので(DIできないし挙動が変わるというのも気持ちが悪い)、`ImmediateScheduler`を指定するのがいいのかもしれません。~~
|
|
107
|
+
~~それにより`DataContext`の設定方法によらず同じ挙動になりました。~~
|
|
108
|
+
|
|
109
|
+
~~ただしUIスレッドを複数作ってはいけない等の制限事項があります。~~
|
|
110
110
|
~~[UI スレッドへのイベントの自動ディスパッチ](https://qiita.com/okazuki/items/7572f46848d0e93516b1#ui-%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89%E3%81%B8%E3%81%AE%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%81%AE%E8%87%AA%E5%8B%95%E3%83%87%E3%82%A3%E3%82%B9%E3%83%91%E3%83%83%E3%83%81-slim-%E3%81%AB%E3%81%AF%E7%84%A1%E3%81%84%E6%A9%9F%E8%83%BD)~~
|
5
対応版がリリースされました(ReactiveProperty 7.10.0)
answer
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
最終的な結論は当該issueを確認してください。
|
|
2
2
|
[2枚目以降のウィンドウでバリデーションエラー赤枠が残る · Issue #258 · runceel/ReactiveProperty](https://github.com/runceel/ReactiveProperty/issues/258)
|
|
3
3
|
|
|
4
|
+
対応版がリリースされました。
|
|
5
|
+
[ReactiveProperty 7.10.0 をリリースしました](https://zenn.dev/okazuki/articles/62a6c6c9d1a12baccc93#7.10.0)
|
|
6
|
+
[Getting start for WPF | ReactiveProperty documentation](https://okazuki.jp/ReactiveProperty/getting-started/wpf.html)
|
|
7
|
+
|
|
4
8
|
全部書き換えたい気分ですが^^; 経緯が分からなくなってしまうので残します。
|
|
5
9
|
が、以下は見る必要はありません。
|
|
6
10
|
|
4
全部書き換えたい気分
answer
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
最終的な結論は当該issueを確認してください。
|
|
2
|
+
[2枚目以降のウィンドウでバリデーションエラー赤枠が残る · Issue #258 · runceel/ReactiveProperty](https://github.com/runceel/ReactiveProperty/issues/258)
|
|
3
|
+
|
|
4
|
+
全部書き換えたい気分ですが^^; 経緯が分からなくなってしまうので残します。
|
|
5
|
+
が、以下は見る必要はありません。
|
|
6
|
+
|
|
1
7
|
~~はっきり言って分かってませんが、~~
|
|
2
8
|
|
|
3
9
|
~~* `ReactivePropertyMode.IgnoreInitialValidationError`を入れる~~
|
|
@@ -93,8 +99,8 @@
|
|
|
93
99
|
|
|
94
100
|
---
|
|
95
101
|
|
|
96
|
-
コードで`DataContext`を設定するという回避法はあんまりなので(DIできないし挙動が変わるというのも気持ちが悪い)、`ImmediateScheduler`を指定するのがいいのかもしれません。
|
|
102
|
+
~~コードで`DataContext`を設定するという回避法はあんまりなので(DIできないし挙動が変わるというのも気持ちが悪い)、`ImmediateScheduler`を指定するのがいいのかもしれません。~~
|
|
97
|
-
それにより`DataContext`の設定方法によらず同じ挙動になりました。
|
|
103
|
+
~~それにより`DataContext`の設定方法によらず同じ挙動になりました。~~
|
|
98
104
|
|
|
99
|
-
ただしUIスレッドを複数作ってはいけない等の制限事項があります。
|
|
100
|
-
[UI スレッドへのイベントの自動ディスパッチ](https://qiita.com/okazuki/items/7572f46848d0e93516b1#ui-%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89%E3%81%B8%E3%81%AE%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%81%AE%E8%87%AA%E5%8B%95%E3%83%87%E3%82%A3%E3%82%B9%E3%83%91%E3%83%83%E3%83%81-slim-%E3%81%AB%E3%81%AF%E7%84%A1%E3%81%84%E6%A9%9F%E8%83%BD)
|
|
105
|
+
~~ただしUIスレッドを複数作ってはいけない等の制限事項があります。~~
|
|
106
|
+
~~[UI スレッドへのイベントの自動ディスパッチ](https://qiita.com/okazuki/items/7572f46848d0e93516b1#ui-%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89%E3%81%B8%E3%81%AE%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%81%AE%E8%87%AA%E5%8B%95%E3%83%87%E3%82%A3%E3%82%B9%E3%83%91%E3%83%83%E3%83%81-slim-%E3%81%AB%E3%81%AF%E7%84%A1%E3%81%84%E6%A9%9F%E8%83%BD)~~
|
3
ImmediateScheduler
answer
CHANGED
|
@@ -89,4 +89,12 @@
|
|
|
89
89
|
public ViewModel() => RP_Text = new ReactiveProperty<string>().SetValidateAttribute(() => RP_Text);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
```
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
コードで`DataContext`を設定するという回避法はあんまりなので(DIできないし挙動が変わるというのも気持ちが悪い)、`ImmediateScheduler`を指定するのがいいのかもしれません。
|
|
97
|
+
それにより`DataContext`の設定方法によらず同じ挙動になりました。
|
|
98
|
+
|
|
99
|
+
ただしUIスレッドを複数作ってはいけない等の制限事項があります。
|
|
100
|
+
[UI スレッドへのイベントの自動ディスパッチ](https://qiita.com/okazuki/items/7572f46848d0e93516b1#ui-%E3%82%B9%E3%83%AC%E3%83%83%E3%83%89%E3%81%B8%E3%81%AE%E3%82%A4%E3%83%99%E3%83%B3%E3%83%88%E3%81%AE%E8%87%AA%E5%8B%95%E3%83%87%E3%82%A3%E3%82%B9%E3%83%91%E3%83%83%E3%83%81-slim-%E3%81%AB%E3%81%AF%E7%84%A1%E3%81%84%E6%A9%9F%E8%83%BD)
|
2
ReactivePropertyが何かおかしい
answer
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
~~どちらかをしたら消えました。~~
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
そういう仕様(という名のバグ?)な気がします(深堀する気はありません)
|
|
9
|
+
~~そういう仕様(という名のバグ?)な気がします(深堀する気はありません)~~
|
|
10
|
-
一番手間がかからなそうな回避策はこんなんでしょうか?(バカバカしいがw
|
|
10
|
+
~~一番手間がかからなそうな回避策はこんなんでしょうか?(バカバカしいがw~~
|
|
11
11
|
|
|
12
12
|
```xaml
|
|
13
13
|
<Window.Resources>
|
|
@@ -21,4 +21,72 @@
|
|
|
21
21
|
</Window.Resources>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
どこかに言及があると思いますし回避策も同じようなものだと思いますが、これといったところを見つけられませんでした^^;
|
|
24
|
+
~~どこかに言及があると思いますし回避策も同じようなものだと思いますが、これといったところを見つけられませんでした^^;~~
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
最小限のコードを作って検証したところ、`ReactiveProperty`が何かおかしいです。
|
|
29
|
+
最初の`Window`は問題ないのですが、そこからさらに`Window`を開くと赤枠が残ります。
|
|
30
|
+
|
|
31
|
+
すべて最新版を使用、.NET48・.NET5とも同様。比較相手は↓です。
|
|
32
|
+
[NuGet Gallery | CommunityToolkit.Mvvm 7.0.1](https://www.nuget.org/packages/CommunityToolkit.Mvvm/)
|
|
33
|
+
[ObservableValidator - Windows Community Toolkit | Microsoft Docs](https://docs.microsoft.com/en-us/windows/communitytoolkit/mvvm/observablevalidator)
|
|
34
|
+
|
|
35
|
+
```xaml
|
|
36
|
+
<Window
|
|
37
|
+
x:Class="Questions334418.MainWindow"
|
|
38
|
+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
39
|
+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
40
|
+
xmlns:local="clr-namespace:Questions334418"
|
|
41
|
+
Width="800"
|
|
42
|
+
Height="450">
|
|
43
|
+
<Window.DataContext>
|
|
44
|
+
<local:ViewModel />
|
|
45
|
+
</Window.DataContext>
|
|
46
|
+
<StackPanel VerticalAlignment="Center">
|
|
47
|
+
<Button Click="Button_Click" Content="open" />
|
|
48
|
+
<TextBox Text="{Binding RP_Text.Value, UpdateSourceTrigger=PropertyChanged}" />
|
|
49
|
+
<TextBox Text="{Binding OV_Text, UpdateSourceTrigger=PropertyChanged}" />
|
|
50
|
+
</StackPanel>
|
|
51
|
+
</Window>
|
|
52
|
+
```
|
|
53
|
+
```C#
|
|
54
|
+
using CommunityToolkit.Mvvm.ComponentModel;
|
|
55
|
+
using Reactive.Bindings;
|
|
56
|
+
using System.ComponentModel.DataAnnotations;
|
|
57
|
+
using System.Windows;
|
|
58
|
+
|
|
59
|
+
namespace Questions334418
|
|
60
|
+
{
|
|
61
|
+
public partial class MainWindow : Window
|
|
62
|
+
{
|
|
63
|
+
public MainWindow()
|
|
64
|
+
{
|
|
65
|
+
InitializeComponent();
|
|
66
|
+
|
|
67
|
+
// xamlのWindow.DataContextが残っていると上書きしようがおかしなまま。
|
|
68
|
+
//DataContext = new ViewModel();
|
|
69
|
+
|
|
70
|
+
var vm = DataContext as ViewModel;
|
|
71
|
+
vm.RP_Text.Value = "a";
|
|
72
|
+
vm.OV_Text = "a";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private void Button_Click(object sender, RoutedEventArgs e) => new MainWindow().Show();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public class ViewModel : ObservableValidator
|
|
79
|
+
{
|
|
80
|
+
[Required(ErrorMessage = "値を入力してください。")]
|
|
81
|
+
//[StringLength(8, ErrorMessage = "8文字以内で入力してください。")]
|
|
82
|
+
public ReactiveProperty<string> RP_Text { get; }
|
|
83
|
+
|
|
84
|
+
[Required(ErrorMessage = "値を入力してください。")]
|
|
85
|
+
//[StringLength(8, ErrorMessage = "8文字以内で入力してください。")]
|
|
86
|
+
public string OV_Text { get => text; set => SetProperty(ref text, value, true); }
|
|
87
|
+
private string text;
|
|
88
|
+
|
|
89
|
+
public ViewModel() => RP_Text = new ReactiveProperty<string>().SetValidateAttribute(() => RP_Text);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
1
回避策
answer
CHANGED
|
@@ -1,6 +1,24 @@
|
|
|
1
|
-
はっきり言って分かってませんが、
|
|
1
|
+
~~はっきり言って分かってませんが、~~
|
|
2
2
|
|
|
3
|
-
* `ReactivePropertyMode.IgnoreInitialValidationError`を入れる
|
|
3
|
+
~~* `ReactivePropertyMode.IgnoreInitialValidationError`を入れる~~
|
|
4
|
-
* `Validation.ErrorTemplate`を設定する
|
|
4
|
+
~~* `Validation.ErrorTemplate`を設定する~~
|
|
5
5
|
|
|
6
|
-
どちらかをしたら消えました。
|
|
6
|
+
~~どちらかをしたら消えました。~~
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
そういう仕様(という名のバグ?)な気がします(深堀する気はありません)
|
|
10
|
+
一番手間がかからなそうな回避策はこんなんでしょうか?(バカバカしいがw
|
|
11
|
+
|
|
12
|
+
```xaml
|
|
13
|
+
<Window.Resources>
|
|
14
|
+
<Style BasedOn="{StaticResource {x:Type TextBox}}" TargetType="{x:Type TextBox}">
|
|
15
|
+
<Style.Triggers>
|
|
16
|
+
<Trigger Property="Validation.HasError" Value="False">
|
|
17
|
+
<Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
|
|
18
|
+
</Trigger>
|
|
19
|
+
</Style.Triggers>
|
|
20
|
+
</Style>
|
|
21
|
+
</Window.Resources>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
どこかに言及があると思いますし回避策も同じようなものだと思いますが、これといったところを見つけられませんでした^^;
|