wpf中没有显示忙线指示灯

本文关键字:指示灯 显示 wpf | 更新日期: 2023-09-27 18:17:31

大家好,我想在我的项目中显示一个Busy Indicator。我正在使用一个后台工作线程,但问题是繁忙的指标是不显示在屏幕上,我不知道是什么。代码是:

XAML是:

<xctk:BusyIndicator Width="200" HorizontalAlignment="Center" 
                    BusyContent="Please wait while the Access controller is configuring "
                    IsBusy="{Binding IsBusy}">
</xctk:BusyIndicator>

c#代码是:

BackgroundWorker _worker = new BackgroundWorker();
{
   _worker.DoWork += (o, ea) =>
    {
      IsBusy = true;
      DiscoverConnectedDevices();
    };
            _worker.RunWorkerCompleted += (o, ea) =>
                {
                    IsDiscoverButtonEnable = true;
                    IsBusy = false;
                    Mouse.OverrideCursor = null;
                    CommandManager.InvalidateRequerySuggested();
                };
            ipmac = new ObservableCollection<IpMacAddressClass>();
        }
 public bool IsBusy
        {
            get
            {
                return _isBusy;
            }
            set
            {
                if(value!=_isBusy)
                {
                    IsBusy = value;
                    OnPropertyChanged("IsBusy");
                }
            }
        }

wpf中没有显示忙线指示灯

您在setter中设置了IsBusy,而不是_isBusy

应:

public bool IsBusy
{
    get
    {
        return _isBusy;
    }
    set
    {
        if(value!=_isBusy)
        {
            _isBusy = value;
            OnPropertyChanged("IsBusy");
        }
    }
}