Страница:
Command
Страницы
BindTagToVisualRootDataContextBehavior
CallMethodAction
ChangePropertyAction
Command
CustomAction
CustomBehavior
DataTriggerBehavior
DragPositionBehavior
EventTriggerBehavior
FocusControlAction
FocusOnAttachedToVisualTreeBehavior
FocusOnPointerMovedBehavior
FocusOnPointerPressedBehavior
Home
InvokeCommandAction
MainWindowViewModel
PopupAction
SelectListBoxItemOnPointerMovedBehavior
ShowPointerPositionBehavior
ToggleIsExpandedOnDoubleTappedBehavior
ViewModelBase
1
Command
Wiesław Šoltés редактировал(а) эту страницу 2017-04-20 13:57:27 +02:00
public class Command : ICommand
{
private Action<object> _execute;
private Predicate<object> _canExecute;
public event EventHandler CanExecuteChanged;
public Command(Action<object> execute = null, Predicate<object> canExecute = null)
{
_execute = execute;
_canExecute = canExecute;
}
public virtual void NotifyCanExecuteChanged()
{
CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
public bool CanExecute(object parameter)
{
return _canExecute?.Invoke(parameter) ?? true;
}
public void Execute(object parameter)
{
_execute?.Invoke(parameter);
}
}
- Introduction
- Behaviors Reference
- Custom Behaviors
- CustomBehavior
- CustomAction
- BindTagToVisualRootDataContextBehavior
- DragPositionBehavior
- FocusOnAttachedToVisualTreeBehavior
- FocusOnPointerMovedBehavior
- FocusOnPointerPressedBehavior
- PopupAction
- SelectListBoxItemOnPointerMovedBehavior
- ShowPointerPositionBehavior
- ToggleIsExpandedOnDoubleTappedBehavior
- FocusControlAction
- MVVM Sources