WPFでSystem.Windows.PointがそのままBindingできるのを知らなかった話
.NET Core 3.0で試してます。それ以外は知りません
結論
いつからなのか、ずっとそうなのか、WPFでSystem.Windows.Pointを編集する際にそのままBindingできました
おしまい
以下だらだらと
試してみる
ViewModel
public class MainViewModel { public ReactiveProperty<Point> Point { get; } = new ReactiveProperty<Point>(); public MainViewModel() { Point.Subscribe(p => System.Diagnostics.Debug.WriteLine("Update : " + p)); } }
これだけ、ReactiveProperty
らくちんちん
View (抜粋)
<TextBlock Text="Point"/> <TextBox Grid.Column="1" Text="{Binding Point.Value}"/>
実行結果
できた!
フォーマット指定もできるよ
Validationももろちん
とりあえず思いつく構造体を並べてみた
全部いけた!!
まとめ
見た目を凝ろうと思ったらやっぱりこれだと辛い(数値はNumericUpDownを求められたり)んですが、とりあえず設定ができればいいレベルのものならこれでいいじゃない
いままでいちいち要素毎に分けていたよ・・・