2010-11-19 6 views
3

私はすでにSilverlightでBusyIndi​​catorをルート要素として宣言し、IsBusyプロパティを生成されたドメインコンテキストのIsLoadingプロパティにバインドすることで、 RIA Servicesによって:Entity Frameworkがデータをロードしているときにビジー状態のインジケーターを表示する

Entity Frameworkので生成されたObjectContextには IsLoading財産がないように思えるので
<toolkit:BusyIndicator IsBusy="{Binding Context.IsLoading}" > 

は、どのように私はWPFでIsBusyプロパティをバインドすることができますか?

は私が思い付いた何

答えて

0

ありがとう:

WPF拡張ツールキットからのビジーインジケータ:私の基本クラスビューモデルで

<extoolkit:BusyIndicator IsBusy="{Binding IsBusy}" BusyContent="Loading data..." > 

を、私は次のメソッドを追加しました:

protected void ExecuteBackgroundProcess(Action action) 
    { 
     IsBusy = true; 

     Task task = Task.Factory.StartNew(() => action()).ContinueWith((s) => this.IsBusy = false); 
    } 

サーバーからコレクションをロードするときは、派生ビューモデル: http://www.codeproject.com/KB/WPF/ThreadingComponent.aspx?msg=3319891

this.ExecuteBackgroundProcess(() => 
{ 
    var collection = _securityRepo.TakeOfType<Security>(10).ToObservableCollection(); 

    DispatcherHelper.CheckBeginInvokeOnUI(() => 
    { 
     Securities = collection; 
     RaisePropertyChanged("Securities"); 
    });      
}); 

CodeProjectの上で、より堅牢な&完全なソリューションもあります

関連する問題