No, WPF evaluates OnClickbefore being Executecalled in a related command.
Depending on what the click handler does; you can call it instead Executeor return the event back to the view model, which then returns the event back to the view, which then executes the code.
Sort of:
Code-Behind:
public SomeViewClass
{
public SomeViewClass()
{
InitializeComponent();
SomeViewModel viewModel = new SomeViewModel;
DataContext = viewModel;
viewModel.SomeCommandCompleted += MoveUp;
}
private void MoveUp()
{
...
}
}
Show model
public class SomeViewModel
{
public event Action SomeCommandCompleted;
public ICommand SomeCommand {get; private set;}
public SomeViewModel()
{
SomeCommand = new DelegateCommand((o) =>
{
...
if (SomeCommandCompleted != null)
SomeCommandCompleted();
}
}
}
source
share