Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>CommandManager</code> doesn't exist in WinRT. You need to manually refresh listeners. Here's my example implementation of <code>DelegateCommand&lt;T&gt;</code> that illustrates this:</p> <pre><code>using System; using System.Windows.Input; public class DelegateCommand&lt;T&gt; : ICommand { private readonly Action&lt;T&gt; m_executeAction; private readonly Predicate&lt;T&gt; m_canExecutePredicate; public DelegateCommand(Action&lt;T&gt; executeAction) : this(executeAction, null) { } public DelegateCommand(Action&lt;T&gt; executeAction, Predicate&lt;T&gt; canExecutePredicate) { if (executeAction == null) { throw new ArgumentNullException("executeAction"); } m_executeAction = executeAction; m_canExecutePredicate = canExecutePredicate; } public event EventHandler Executed; public event EventHandler CanExecuteChanged; bool ICommand.CanExecute(object parameter) { return CanExecute((T)parameter); } void ICommand.Execute(object parameter) { Execute((T)parameter); } public bool CanExecute(T parameter) { var result = true; var canExecutePredicate = m_canExecutePredicate; if (canExecutePredicate != null) { result = canExecutePredicate(parameter); } return result; } public void Execute(T parameter) { m_executeAction(parameter); RaiseExecuted(); } public void Refresh() { RaiseCanExecuteChanged(); } protected virtual void RaiseExecuted() { var handler = Executed; if (handler != null) { handler(this, EventArgs.Empty); } } protected virtual void RaiseCanExecuteChanged() { var handler = CanExecuteChanged; if (handler != null) { handler(this, EventArgs.Empty); } } } </code></pre> <p>The WPF version of this class indirectly uses <code>CommandManager.InvalidateRequerySuggested</code> by implementing <code>CanExecuteChanged</code> as follows:</p> <pre><code>public event EventHandler CanExecuteChanged { add { CommandManager.RequerySuggested += value; } remove { CommandManager.RequerySuggested -= value; } } </code></pre> <p>However, in WinRT this is not supported and in my WinRT version any code that invalidates the state of the delegate command must call the <code>Refresh</code> method to cause bound items in the view to requery the command.</p> <p>I think the best solution to your specific problem would be to implement <code>INotifyPropertyChanged</code> in your view model. Invoking the <code>PropertyChanged</code> event on this interface is equivalent to my <code>Refresh</code> method and forces bound elements in the view to re-evaluate themselves and, thus, to re-run all associated <code>IValueConverter</code> instances.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload