WPF loading spinner

后端 未结 14 837
我寻月下人不归
我寻月下人不归 2020-12-02 05:30

The goal is to display the information that the application is working. So I\'m looking for an intelligent implementation sample of a loading spinner using WPF / MVVM.

14条回答
  •  攒了一身酷
    2020-12-02 06:00

    use an enum type to indicate your ViewModel's State

    public enum ViewModeType
    {
        Default, 
        Busy
        //etc.
    }
    

    then in your ViewModels Base class use a property

    public ViewModeType ViewMode
    {
        get { return this.viewMode; }
        set
        {
            if (this.viewMode != value)
            {
                this.viewMode = value;
                                //You should notify property changed here
            }
        }
    }
    

    and in view trigger the ViewMode and if it is busy show busyindicator:

    
        
    
    

提交回复
热议问题