Skip to content

Improve ICommand docs #7721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 50 additions & 50 deletions xml/System.Windows.Input/ICommand.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,42 @@
<Docs>
<summary>Defines a command.</summary>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
<xref:System.Windows.Input.RoutedCommand> and <xref:System.Windows.Input.RoutedUICommand> are two implementations of the <xref:System.Windows.Input.ICommand> interface in Windows Presentation Foundation (WPF).

## ICommand in Windows Runtime apps
The <xref:System.Windows.Input.ICommand> interface is the code contract for commands that are written in .NET for Windows Runtime apps. These commands provide the commanding behavior for UI elements such as a Windows Runtime XAML `Button` and in particular an `AppBarButton`. If you're defining commands for Windows Runtime apps you use basically the same techniques you'd use for defining commands for a .NET app. Implement the command by defining a class that implements <xref:System.Windows.Input.ICommand> and specifically implement the <xref:System.Windows.Input.ICommand.Execute%2A> method.

XAML for Windows Runtime does not support x`:Static`, so don't attempt to use the `x:Static` markup extension if the command is used from Windows Runtime XAML. Also, the Windows Runtime does not have any predefined command libraries, so the XAML syntax shown here doesn't really apply for the case where you're implementing the interface and defining the command for Windows Runtime usage.

<a name="xamlTextUsage_ICommand"></a>
## XAML Attribute Usage
\<*object property*="*predefinedCommandName*"/>

<format type="text/markdown"><![CDATA[

## Remarks

<xref:System.Windows.Input.RoutedCommand> and <xref:System.Windows.Input.RoutedUICommand> are two implementations of the <xref:System.Windows.Input.ICommand> interface in Windows Presentation Foundation (WPF).

## ICommand in Windows Runtime apps

The <xref:System.Windows.Input.ICommand> interface is the code contract for commands that are written in .NET for Windows Runtime apps. These commands provide the commanding behavior for UI elements such as a Windows Runtime XAML `Button` and in particular an `AppBarButton`. If you're defining commands for Windows Runtime apps, you use basically the same techniques you'd use for defining commands for a .NET app. Implement the command by defining a class that implements <xref:System.Windows.Input.ICommand> and specifically implement the <xref:System.Windows.Input.ICommand.Execute%2A> method.

XAML for Windows Runtime does not support `x:Static`, so don't attempt to use the `x:Static` markup extension if the command is used from Windows Runtime XAML. Also, the Windows Runtime does not have any predefined command libraries, so the XAML syntax shown here doesn't really apply for the case where you're implementing the interface and defining the command for Windows Runtime usage.

## XAML attribute usage

```xaml
<object-property="predefined-command-name"/>
-or-

\<*object property*="*predefinedClassName.predefinedCommandName*"/>

<object-property="predefined-class-name.predefined-command-name"/>
-or-
\<*object property*="{ *customClassName.customCommandName*}"/>
<a name="xamlValues_ICommand"></a>
## XAML Values
*predefinedClassName*
One of the predefined command classes.
*predefinedCommandName*
One of the predefined commands.
*customClassName*
A custom class that contains the custom command. Custom classes generally require an `xlmns` prefix mapping; see [XAML Namespaces and Namespace Mapping for WPF XAML](/dotnet/framework/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml).
*customCommandName*
A custom command.
<object-property="{custom-class-name.custom-command-name}"/>
```

## XAML values

`predefined-class-name`\
One of the predefined command classes.

`predefined-command-name`\
One of the predefined commands.

`custom-class-name`\
A custom class that contains the custom command. Custom classes generally require an `xlmns` prefix mapping. For more information, see [XAML Namespaces and Namespace Mapping for WPF XAML](/dotnet/framework/wpf/advanced/xaml-namespaces-and-namespace-mapping-for-wpf-xaml).

`custom-command-name`\
A custom command.

]]></format>
</remarks>
</Docs>
Expand Down Expand Up @@ -169,16 +169,17 @@
<Parameter Name="parameter" Type="System.Object" />
</Parameters>
<Docs>
<param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
<summary>Defines the method that determines whether the command can execute in its current state.</summary>
<param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
<summary>Determines whether the command can execute in its current state.</summary>
<returns>
<see langword="true" /> if this command can be executed; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
Typically, a command source calls the <xref:System.Windows.Input.ICommand.CanExecute%2A> method when the <xref:System.Windows.Input.ICommand.CanExecuteChanged> event is raised.

<format type="text/markdown"><![CDATA[

## Remarks

Typically, a command source calls the <xref:System.Windows.Input.ICommand.CanExecute%2A> method when the <xref:System.Windows.Input.ICommand.CanExecuteChanged> event is raised.

]]></format>
</remarks>
<altmember cref="T:System.Windows.Input.ICommandSource" />
Expand Down Expand Up @@ -229,15 +230,14 @@
<ReturnType>System.EventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when changes occur that affect whether or not the command should execute.</summary>
<summary>Occurs when changes take place that affect whether or not the command should execute.</summary>
<remarks>
<format type="text/markdown"><![CDATA[

## Remarks
Normally, a command source calls <xref:System.Windows.Input.ICommand.CanExecute%2A> on the command when this event occurs.

Normally, if the command cannot execute, the command source disables itself.

<format type="text/markdown"><![CDATA[

## Remarks

Normally, a command source calls <xref:System.Windows.Input.ICommand.CanExecute%2A> on the command when this event occurs. If the command cannot execute, the command source disables itself.

]]></format>
</remarks>
<altmember cref="T:System.Windows.Input.ICommandSource" />
Expand Down Expand Up @@ -291,7 +291,7 @@
<Parameter Name="parameter" Type="System.Object" />
</Parameters>
<Docs>
<param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
<param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to <see langword="null" />.</param>
<summary>Defines the method to be called when the command is invoked.</summary>
<remarks>To be added.</remarks>
<altmember cref="T:System.Windows.Input.ICommandSource" />
Expand Down
Loading