Q:

Caliburn. Micro not updating UI

I'm trying to build simple utility with caliburn micro and wpf.  This simple code:
    public bool CanTransfer
    {
        get { return this.canTransfer; }
        set
        {
            this. NotifyOfPropertyChange(() => this. CanTransfer);
            this.canTransfer = value;
        }
    }

    public void Transfer()
    {
        Task. Factory. StartNew(this. Process);
    }

    private void Process()
    {
        this. CanTransfer = false;
        Thread. Sleep(5000);
        this. CanTransfer = true;
    }

Does the following - Transfer button remains disabled, but I'd expect it to be enabled 5 seconds after, what am I doing wrong? 

A:

Swap those lines in CanTransfer setter method - now you first say something has changed while it actually hasn't and then you change it:
public bool CanTransfer
{
    get { return this.canTransfer; }
    set
    {
        this.canTransfer = value;
        this. NotifyOfPropertyChange(() => this. CanTransfer);
    }
}

I usually use method like ChangeAndNotify<T> (the only annoyance is declaration of the field), the code can be seen here:
private bool _canTransfer;
public string CanTransfer
{
  get { return _canTransfer; }
  set 
  { 
    PropertyChanged. ChangeAndNotify(ref _canTransfer, value, () => CanTransfer); 
  }
}

