all. I can't seem to figure out what's going on here. I've researched the docs, and opened up the assemblies to see the code. Doesn't make sense.
I'm working in UWP and trying to create commands that inherit from XamlUICommand. ICommand has the method Execute(Object parameter) (https://learn.microsoft.com/en-us/dotnet/api/system.windows.input.icommand?view=netframework-4.8). XamlUICommand implements ICommand, and so must (?) implement that Execute() method. The docs( here: https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.input.xamluicommand) say that it does implement the method, but when attempting to override the method:
public class SendConfigToBoard : XamlUICommand
{
public override void Execute(Object parameter)
{
}
}
I get the error: No suitable method found to override. When I open up the assembly and inspect XamlUICommand, it doesn't appear to implement the method, but all of my understanding says that it must implement that method, correct?
ICommand
#region Assembly System.ObjectModel, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Program Files (x86)\Microsoft SDKs\UWPNuGetPackages\microsoft.netcore.universalwindowsplatform\6.2.9\ref\uap10.0.15138\System.ObjectModel.dll
#endregion
namespace System.Windows.Input
{
//
// Summary:
// Defines a command.
public interface ICommand
{
//
// Summary:
// Occurs when changes occur that affect whether or not the command should execute.
event EventHandler CanExecuteChanged;
//
// Summary:
// Defines the method that determines whether the command can execute in its current
// state.
//
// Parameters:
// parameter:
// Data used by the command. If the command does not require data to be passed,
// this object can be set to null.
//
// Returns:
// true if this command can be executed; otherwise, false.
bool CanExecute(object parameter);
//
// Summary:
// Defines the method to be called when the command is invoked.
//
// Parameters:
// parameter:
// Data used by the command. If the command does not require data to be passed,
// this object can be set to null.
void Execute(object parameter);
}
}
XamlUICommand
namespace Windows.UI.Xaml.Input
{
//
// Summary:
// Implements the ICommand interface, adding various UI properties, methods, and
// events to provide a base class for defining the command behavior of an interactive
// UI element that performs an action when invoked (such as sending an email, deleting
// an item, or submitting a form).
[Composable(typeof(IXamlUICommandFactory), CompositionType.Public, 458752, "Windows.Foundation.UniversalApiContract")]
[ContractVersion(typeof(UniversalApiContract), 458752)]
[MarshalingBehavior(MarshalingType.Agile)]
[Static(typeof(IXamlUICommandStatics), 458752, "Windows.Foundation.UniversalApiContract")]
[Threading(ThreadingModel.Both)]
[WebHostHidden]
public class XamlUICommand : DependencyObject, IXamlUICommand, ICommand
{
//
// Summary:
// Initializes a new instance of the XamlUICommand class.
public XamlUICommand();
//
// Summary:
// Notifies the system that the command state has changed.
public void NotifyCanExecuteChanged();
//
// Summary:
// Gets or sets the label for this element.
//
// Returns:
// The label for this element.
public string Label { get; set; }
//
// Summary:
// Gets or sets a glyph from the Segoe MDL2 Assets font for this element.
//
// Returns:
// A glyph from the Segoe MDL2 Assets font for this element.
public IconSource IconSource { get; set; }
//
// Summary:
// Gets or sets a description for this element.
//
// Returns:
// The description for this element.
public string Description { get; set; }
//
// Summary:
// Gets or sets the command behavior of an interactive UI element that performs
// an action when invoked, such as sending an email, deleting an item, or submitting
// a form.
//
// Returns:
// The command behavior of the element.
public ICommand Command { get; set; }
//
// Summary:
// Gets or sets the access key (mnemonic) for this element.
//
// Returns:
// The access key (mnemonic) for this element.
public string AccessKey { get; set; }
//
// Summary:
// Gets or sets the collection of key combinations for this element that invoke
// an action using the keyboard.
//
// Returns:
// The keyboard accelerators for this element.
public IList<KeyboardAccelerator> KeyboardAccelerators { get; }
//
// Summary:
// Identifies the AccessKey dependency property.
//
// Returns:
// The identifier for the AccessKey dependency property.
public static DependencyProperty AccessKeyProperty { get; }
//
// Summary:
// Identifies the Command dependency property.
//
// Returns:
// The identifier for the Command dependency property.
public static DependencyProperty CommandProperty { get; }
//
// Summary:
// Identifies the Description dependency property.
//
// Returns:
// The identifier for the Description dependency property.
public static DependencyProperty DescriptionProperty { get; }
//
// Summary:
// Identifies the IconSource dependency property.
//
// Returns:
// The identifier for the IconSource dependency property.
public static DependencyProperty IconSourceProperty { get; }
//
// Summary:
// Identifies the KeyboardAccelerators dependency property.
//
// Returns:
// The identifier for the KeyboardAccelerators dependency property.
public static DependencyProperty KeyboardAcceleratorsProperty { get; }
//
// Summary:
// Identifies the Label dependency property.
//
// Returns:
// The identifier for the Label dependency property.
public static DependencyProperty LabelProperty { get; }
//
// Summary:
// Occurs when a CanExecute call is made.
public event TypedEventHandler<XamlUICommand, CanExecuteRequestedEventArgs> CanExecuteRequested;
//
// Summary:
// Occurs when an Execute call is made.
public event TypedEventHandler<XamlUICommand, ExecuteRequestedEventArgs> ExecuteRequested;
}
}
I hope I didn't miss anything easy here. Can anyone explain why either/both I can't override the method and/or why XamlUICommand doesn't implement ICommand.Execute(Object parameter)?