Silverlight的BusyIndicator控件,我可以解僱例如繁忙的指標相當於Silverlight和MVVM在MVC
public class ViewModelBase : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
private bool _isBusy;
public bool IsBusy
{
get
{
return _isBusy;
}
set
{
_isBusy = value;
RaisePropertyChanged("IsBusy");
}
}
ObervableCollection<OperationBase> _pendingOperations = new ObervableCollection<OperationBase>();
public ViewModelBase()
{
_pendingOperations.CollectionChanged +=(s,e)=>
{
if(_pendingOperations.Count > 0)
IsBusy = true // has operation going on
else
IsBusy = false; //no operation
}
}
void LoadData()
{
LoadOperation op = Context.Load(YourQuery, lo=>
{
_pendingOperations.Remove(lo); // lo is the operation, remove it
if (lo.HasError)
{
lo.MarkErrorAsHandled();
MessageBox.Show(lo.Error.Message);
}
});
_pendingOperations.Add(op);// add operation to the collection
}
void SaveData()
{
SubmitOperation so = this.context.SubmitChanges(s =>
{
_pendingOperations.Remove(s);
if (s.HasError)
{
s.MarkErrorAsHandled();
MessageBox.Show(s.Error.Message);
}
}, null);
_pendingOperations.Add(so);// add operation to the collection }
}
...
}
我想要做同樣的MVC,任何想法如何做到這一點,例如搜索,創建或者任何長期的過程,我需要表現出繁忙的指標,並在年底關閉它,我知道有沒有改變性質,我不知道是否療法的任何方式
在ASP.NET MVC?然後你需要在Javascript中完成它。 –
任何想法如何使其通用像繁忙指標 – AMH