How do you manually refresh a window in WPF?

I use the ICommand interface to bind to a couple of buttons in my application - the Start and Close button. I use the helper method mentioned in this to connect ICommand to the delegate as follows:

_someCommand = new DelegateCommand(this.DoSomething, this.CanDoSomething);

private ICommand _someCommand;

public ICommand SomeCommand
{
    get { return _someCommand; }
}

private void DoSomething(object state)
{
    // do something here
}

private bool CanDoSomething(object state)
{
    // return true/false here is enabled/disable button
}

This seems to work just fine, since in my implementation CanDoSomething returns the value of the property that I have in my application.

If I set the initial value of the property to true, the button will be enabled and false will be disabled.

I have a series of events that are raised from BackgroundWorkerthe application level back to the ViewModel, which change the value of the property as true or false based on the current state of the application.

, , , " ", true . - , . , , , , . , , , .

- , .

!

-

. "". . SQL , , , .

, , , , , , . , , , .

+3
2

CommandManager.InvalidateRequerySposed() - , .

+4

Source: https://habr.com/ru/post/1759808/


All Articles