BusyIndicator using MVVM 忙碌状态指示器的的实现

ViewModel 视图模型

 

public abstract class ViewModelBase : INotifyPropertyChanged

{

    private bool isbusy;



    public bool IsBusy

    {

        get

        {

            return isbusy;

        }

        set

        {

            isbusy = value;

            RaisePropertyChanged("IsBusy");

        }

    }



    public event PropertyChangedEventHandler PropertyChanged;



    protected void RaisePropertyChanged(string propertyName)

    {

        PropertyChangedEventHandler handler = PropertyChanged;



        if (handler != null)

        {

            handler(this, new PropertyChangedEventArgs(propertyName));

        }

    }

}

 

 

View 视图

 

<extWpfTk:BusyIndicator IsBusy="{Binding IsBusy}">

        <ContentControl />

    </extWpfTk:BusyIndicator>

 

IsBusy = true 时,  BusyIndicator 就开始显示出来

 

 参考网址 http://stackoverflow.com/questions/12384012/busyindicator-using-mvvm

Extended WPF Toolkit 下载地址 http://wpftoolkit.codeplex.com/releases/view/99072

 

 

 

 

 

你可能感兴趣的:(cat)