LoginSignup
5
2

More than 3 years have passed since last update.

ReactiveProperty<>からの一つの判定をかませてReactiveCommandを作る覚え書き

Posted at

Listとかで選択されるとCommandが有効になるとか

今更とか言わないで。

例えば、

<DataGrid
    SelectedItem="{Binding SelectedData.Value, Mode=TwoWay}"
    />
<Button
    Command="{Binding ItemSelectedCommand}"
    Content="Execute"
    />

みたいな。
すると、

public ReactiveProperty<ItemData> SelectedData { get; } = new ReactiveProperty<ItemData>();
public ReactiveCommand ItemSelectedCommand { get; private set; }

として、

ItemSelectedCommand = SelectedData
    .Any(data => data != null)
    .ToReactiveCommand();

とすればよいようだ。
なるほど。

5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2