語言

Run 類別

定義

代表一個獨立的格式化或未格式文字區塊。

public ref class Run sealed : Inline
/// [Microsoft.UI.Xaml.Markup.ContentProperty(Name="Text")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class Run final : Inline
[Microsoft.UI.Xaml.Markup.ContentProperty(Name="Text")]
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class Run : Inline
Public NotInheritable Class Run
Inherits Inline
<Run .../>
-or-
<Run ...>text</Run>
繼承
Object Platform::Object IInspectable DependencyObject TextElement Inline Run
屬性

範例

此處展示的每個範例結果都相同。 不過,直接在 TextBlock 上設定 Text 屬性的效能最佳。

<!-- Set the TextBlock.Text property directy for best performance. -->
<TextBlock Text="This is some text."/>

<TextBlock><Run>This is some text.</Run></TextBlock>

<TextBlock><Run Text="This is some text."></Run></TextBlock>
// Set the TextBlock.Text property directy for best performance.
TextBlock textblock = new TextBlock();
textblock.Text = "This is some text.";

TextBlock textblock = new TextBlock();
Run run = new Run();
run.Text = "This is some text.";
textblock.Inlines.Add(run);

備註

Run 代表一個獨立的格式化或未格式文字區塊,可用於 TextBlock 或 RichTextBlock。 你可以在 一個跨度內放置多個 Run 元素。

使用 TextBlock 時,直接設定 TextBlock.Text 屬性以提升最佳效能。 通常只有在想格式化 TextBlock 內獨立的文字區塊時,才會使用 Run 元素。

更多範例請參見

建構函式

名稱 Description
Run()

初始化一個新的 Run 類別實例。

屬性

名稱 Description
AccessKey

取得或設定此元素的存取金鑰。

(繼承來源 TextElement)
AccessKeyScopeOwner

取得或設定一個來源元素,提供該元素的存取鍵作用域,即使該元素不在原始元素的視覺樹中。

(繼承來源 TextElement)
AllowFocusOnInteraction

會獲得或設定一個值,指示該元素在使用者互動時是否自動獲得焦點。

(繼承來源 TextElement)
CharacterSpacing

取得或設定字元間的均勻間距,單位為 1/1000 的 em。

(繼承來源 TextElement)
ContentEnd

會得到一個 TextPointer ,代表元素中內容的結尾。

(繼承來源 TextElement)
ContentStart

會取得一個 TextPointer ,代表元素中內容的起始。

(繼承來源 TextElement)
Dispatcher

它總是在 Windows 應用程式 SDK 應用程式中回傳 null 。 改用 DispatcherQueue 。

(繼承來源 DependencyObject)
DispatcherQueue

得到 DispatcherQueue 這個物件所關聯的那個。 代表 DispatcherQueue 一個功能,即使程式碼是由非 UI 執行緒發起,也能存取 UI DependencyObject 執行緒。

(繼承來源 DependencyObject)
ElementEnd

會得到一個 TextPointer ,代表元素結束後的位置。

(繼承來源 TextElement)
ElementStart

會取得一個 TextPointer ,代表元素開始前的位置。

(繼承來源 TextElement)
ExitDisplayModeOnAccessKeyInvoked

取得或設定一個值,指定在呼叫存取鍵時是否會關閉存取鍵顯示。

(繼承來源 TextElement)
FlowDirection

它會取得或設定文字及其他使用者介面元素在控制其版面配置的 Run 元素內流動的方向。

FlowDirectionProperty

識別 FlowDirection 依賴性質。

FontFamily

取得或設定元素內容的首選頂層字型家族。

(繼承來源 TextElement)
FontSize

它會取得或設定元素內容的字型大小。

(繼承來源 TextElement)
FontStretch

取得或設定字型在家族中要選擇的字型寬度。

(繼承來源 TextElement)
FontStyle

取得或設定此元素內容的字體樣式。

(繼承來源 TextElement)
FontWeight

取得或設定頂層字體權重,以便從該元素內容的字型家族中選擇。

(繼承來源 TextElement)
Foreground

取得或設定筆 刷 套用到這個元素的內容上。

(繼承來源 TextElement)
IsAccessKeyScope

取得或設定一個值,指示元素是否定義其存取鍵作用域。

(繼承來源 TextElement)
IsTextScaleFactorEnabled

取得或設定是否啟用自動文字放大(反映系統文字大小設定)。

(繼承來源 TextElement)
KeyTipHorizontalOffset

取得或設定一個值,表示按鍵點與文字元素相對的左或右位置。

(繼承來源 TextElement)
KeyTipPlacementMode

取得或設定一個值,指示鍵尖與文字元素相對於的位置。

(繼承來源 TextElement)
KeyTipVerticalOffset

取得或設定一個值,表示鍵尖相對於文字元素的上下位置。

(繼承來源 TextElement)
Language

取得或設定適用於 TextElement 的在地化/全球化語言資訊。

(繼承來源 TextElement)
Name

取得或設定該物件的唯一識別碼。 名稱只能從 XAML 的初始解析中設定。

(繼承來源 TextElement)
Text

取得或設定 Run 的文字內容。

TextDecorations

取得或設定一個值,指示文字上所施加的裝飾。

(繼承來源 TextElement)
XamlRoot

取得或設定該元素正在被查看的 XamlRoot。

(繼承來源 TextElement)

方法

名稱 Description
ClearValue(DependencyProperty)

清除依賴性財產的局部價值。

(繼承來源 DependencyObject)
FindName(String)

透過參考物件的 x:Name 或 Name 屬性值,在物件模型/執行時物件圖中取得物件。

(繼承來源 TextElement)
GetAnimationBaseValue(DependencyProperty)

回傳任何為相依屬性建立的基礎值,適用於動畫未啟用時。

(繼承來源 DependencyObject)
GetValue(DependencyProperty)

回傳 DependencyObject 中相依屬性的當前有效值。

(繼承來源 DependencyObject)
OnDisconnectVisualChildren()

覆寫此方法,實作當類別特定內容或子屬性移除項目時,版面配置與邏輯應如何運作。

(繼承來源 TextElement)
ReadLocalValue(DependencyProperty)

若設定了本地值,則回傳依賴性質的局部值。

(繼承來源 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

註冊一個通知函式,用於監聽此 DependencyObject 實例中特定 DependencyProperty 的變更。

(繼承來源 DependencyObject)
SetValue(DependencyProperty, Object)

將相依屬性的局部值設定在 DependencyObject 上。

(繼承來源 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消先前透過呼叫 RegisterPropertyChangedCallback 註冊的變更通知。

(繼承來源 DependencyObject)

事件

名稱 Description
AccessKeyDisplayDismissed

當存取鍵序列完成時,會通知控制單位應該隱藏存取鍵視覺。

(繼承來源 TextElement)
AccessKeyDisplayRequested

當存取鍵序列啟動時,會通知控制單位應該顯示存取鍵視覺化。

(繼承來源 TextElement)
AccessKeyInvoked

當使用者完成一個存取金鑰序列,通知元素應該呼叫存取金鑰動作時,會發生這種情況。

(繼承來源 TextElement)

適用於

另請參閱