Search code examples
c#wpfbackgroundworkerbusyindicator

Busy indicator is not displaying in wpf?


Hi guys i want to display a Busy Indicator in my project.I am using a background worker thread but the problem is Busy Indicator is not displaying on the screen i dont know what is the .The code is:

XAML is:

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

</xctk:BusyIndicator>

C# code is:

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");
                }
            }
        }

Solution

  • You are setting IsBusy within your setter, rather than _isBusy

    Should be:

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