WPF MVVMプロジェクトで作業しています。WPF UIの変更が延期される
VieModelの内部では、長いプロセスを開始する前にコントロールを非表示にしたいと考えています。次のように
コマンドコードは次のようになります。
private RelayCommand _DeleteCommand;
public RelayCommand DeleteCommand
{
get
{
return _DeleteReferenceCommand
?? (_DeleteReferenceCommand = new RelayCommand(
() =>
{
GridViewVisibility = false;
//Long process....
},
() => { return ReferencesGridWithPicsUC.SelectedReference != null; }
));
}
}
GridViewVisibilityは、ビューに私のコントロールの可視性にバインドされ、raiseeventを使用しています。 looongプロセスの後で、コマンドが返った後に可視性が実際に更新される点を除いて、正常に動作します。 私は明らかにそれができるだけ早く更新したい。
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
GridViewVisibility = false));
同じ結果と
GridViewVisibility = false;
:
は私がディスパッチャと置き換えを使用してみました。どうすれば動作させることができますか?
'GridViewVisibility = false'を設定した後、ロングプロセスを非同期に実行しようとしないのはなぜですか? – ViVi