Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MVVM: Why RelayCommand not get update button disable/enable right way?

$
0
0
We have practiced MVVM pattern.
We create two ICommand StartCommand and StopCommand

  public ICommand StartCommand
    {
      get
      {
        if (_StartCommand == null)
        {
          _StartCommand = new RelayCommand(
              param => this.Start(),
              param => this.CanStart
              );
        }
        return _StartCommand;
      }
    }


We use instrument status to decide enable/disable Start and Stop button.

When we use backgroundthread to get data from instrument simulator to update UI'status.
After clicking the Start button, we start the background thread to get instrument status.
The Stop button enable/disable does not get updat right way.
If we click the Window/view area, then the Stop button get update.
It looks like after click the window/view area, the CanStop function get called.

Does anybody know why? 
Thx!

Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>