public ICommand OpenDialogFile
{
get
{
return new DelegateCommand<RichEditBox>(OpenDialogToAttach);
}
}
Command="{Binding OpenDialogFile}" CommandParameter="{Binding ElementName=TweetEditBox}"
Итак, DeledateCommand действительно знает о RichEditBox. Хотя я использую «Неопределенный тип 'DelegateCommand' не может использоваться с аргументами типа
OpenDialogToAttach (RichEditBox editBox)".
Как это решить ?. Я дебютирую на UWP.
Вот DelegateCommand Code.Initializes новый экземпляр класса DelegateCommand, что
internal class DelegateCommand : ICommand
{
private readonly Action _execute;
private readonly Func<bool> _canExecute;
/// <summary>
/// Initializes a new instance of the RelayCommand class that
/// can always execute.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <exception cref="ArgumentNullException">If the execute argument is null.</exception>
public DelegateCommand(Action execute)
: this(execute, null)
{
}
/// <summary>
/// Initializes a new instance of the RelayCommand class.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
/// <exception cref="ArgumentNullException">If the execute argument is null.</exception>
public DelegateCommand(Action execute, Func<bool> canExecute)
{
if (execute == null)
{
throw new ArgumentNullException("execute");
}
_execute = execute;
_canExecute = canExecute;
}
/// <summary>
/// Occurs when changes occur that affect whether the command should execute.
/// </summary>
public event EventHandler CanExecuteChanged;
/// <summary>
/// Raises the <see cref="CanExecuteChanged" /> event.
/// </summary>
[SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate",
Justification = "This cannot be an event")]
public void RaiseCanExecuteChanged()
{
var handler = CanExecuteChanged;
if (handler != null)
{
handler(this, EventArgs.Empty);
}
}
/// <summary>
/// Defines the method that determines whether the command can execute in its current state.
/// </summary>
/// <param name="parameter">This parameter will always be ignored.</param>
/// <returns>true if this command can be executed; otherwise, false.</returns>
[DebuggerStepThrough]
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute();
}
/// <summary>
/// Defines the method to be called when the command is invoked.
/// </summary>
/// <param name="parameter">This parameter will always be ignored.</param>
public void Execute(object parameter)
{
if (CanExecute(parameter))
{
_execute();
}
}
}
который делегат комманды вы используете? шо ваш импорт заявления –
'общественного DelegateCommand (Действие выполнить, Func CanExecute) { если (выполнение == NULL) { певд ArgumentNullException ("выполнить"); } _execute = выполнить; _canExecute = canExecute; } ' –
Вы показываете мне конструктор, не используя инструкцию. Итак, это ваш класс ... вам нужно добавить свое тело к вопросу. Я не думаю, что ваш класс является общим –