語言

EditingCommands.AlignCenter 屬性

定義

代表 AlignCenter 指令,請求當前段落或部分段落置中。

public:
 static property System::Windows::Input::RoutedUICommand ^ AlignCenter { System::Windows::Input::RoutedUICommand ^ get(); };
public static System.Windows.Input.RoutedUICommand AlignCenter { get; }
static member AlignCenter : System.Windows.Input.RoutedUICommand
Public Shared ReadOnly Property AlignCenter As RoutedUICommand

屬性值

命令。 此指令的預設按鍵手勢為 Ctrl+E。

範例

以下範例示範如何在支援該指令的物件上呼叫編輯指令。

在此例子中,a RichTextBox 作為指令目標。 請注意,該RichTextBoxIInputElement介面FrameworkElement實作自 ,且包含對許多編輯指令的原生支援。

該方法的 Execute 第一個參數是一個指令參數。 大多數編輯指令會忽略指令參數;一般來說,這個參數應該用於 null 編輯指令。

第二個參數指定指令將被路由到哪個物件。 此物件必須實作介面, IInputElement 並應包含指定指令的處理器。 一般來說,當指令在未處理該指令的物件上被呼叫時,會被忽略。

RichTextBox rTB = new RichTextBox();

EditingCommands.ToggleInsert.Execute(null, rTB);
Dim rTB As New RichTextBox()

EditingCommands.ToggleInsert.Execute(Nothing, rTB)

備註

此指令在層 Paragraph 級運作。 若對段落中部分內容(包括插入點位於段落內的空選取)觸發此命令,則該請求效果會套用至整個段落。 若此命令被調用於跨越多個段落的選取,則該效果會套用到參與選取的每個段落的全部內容。

下圖展示了居中內容的範例。

截圖:Center的TextAlign屬性值 截

此指令原生由 支援。RichTextBox

XAML 屬性使用方式

<object property="AlignCenter"/>

適用於

另請參閱