public void Execute(object parameter) { var target = _reference.Target as IViewModel; if (target == null) { return; } if (NestedCommand == null) { _provider.TryCloseViewModel(target, parameter); } else { NestedCommand.Execute(parameter); } }