This documentation is archived and is not being maintained.

EditingCommands.AlignJustify Property

Represents the AlignJustify command, which requests that the current paragraph or a selection of paragraphs be justified.

Namespace: System.Windows.Documents
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public static RoutedUICommand AlignJustify { get; }
/** @property */
public static RoutedUICommand get_AlignJustify ()

public static function get AlignJustify () : RoutedUICommand

<object property="AlignJustify"/>

Property Value

The requested command. The default key gesture for this command is Ctrl+J.

This command operates at the Paragraph level. If this command is invoked on a partial selection of content within a paragraph (including an empty selection where the caret is within a paragraph), the requested effect will be applied to the entire paragraph. If this command is invoked on a selection that spans multiple paragraphs, the effect will be applied to all the paragraphs in the selection.

When content is justified, the horizontal spacing within each line of content is adjusted so that the justified lines are of equal or near-equal width. Content is typically justified to create smooth edges on the sides of the content.

Because it is often shorter than the rest, the last line in a paragraph may remain unjustified after this command is invoked.

The following figure shows unjustified (left-aligned) content.

Screenshot: Content is unjustified

The following figure shows the same content after it has been justified.

Screenshot of content justified text

There is not necessarily an actual implementation that responds to this command on any given object; in many cases the implementation that responds to a command is the responsibility of the application writer.

This command is natively supported by RichTextBox.

The following example demonstrates how to invoke an editing command on an object that supports the command.

For this example, a RichTextBox serves as the command target. Note that RichTextBox implements the IInputElement interface (inherited from FrameworkElement), and that it includes native support for many editing commands.

The first argument for the Execute method is a command parameter. Most editing commands ignore the command parameter; in general this parameter should be left null for editing commands.

The second argument specifies the object to which the command will be routed. This object must implement the IInputElement interface, and should include a handler for the specified command. Generally, a command is ignored when invoked on an object that does not handle the command.

RichTextBox rTB = new RichTextBox();

EditingCommands.ToggleInsert.Execute(null, rTB);

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: