public static WpfProxy FromObject(object obj) { WpfObjectProxy proxy = obj as WpfObjectProxy; if (proxy != null) { return(proxy._provider); } return(null); }
public Task Execute(RoutedCommand command, object target, object parameter, CancellationToken?token = null) { target = WpfObjectProxy.UnwrapIfProxy(target); if (!(target is IInputElement)) { throw new InvalidOperationException("Cannot execute command on " + ToString()); } parameter = WpfObjectProxy.UnwrapIfProxy(parameter); return(InvokeAsync(() => command.Execute(parameter, target as IInputElement), token: token ?? DefaultCancellationToken)); }
public bool CanExecute(RoutedCommand command, object target, object parameter) { target = WpfObjectProxy.UnwrapIfProxy(target); if (!(target is IInputElement)) { return(false); } parameter = WpfObjectProxy.UnwrapIfProxy(parameter); return(Invoke( () => command.CanExecute(parameter, (IInputElement)target), DispatcherPriority.SystemIdle )); }
internal static object UnwrapIfProxy(object value) { WpfObjectProxy proxy = value as WpfObjectProxy; return((proxy != null) ? proxy._object : value); }