TextChangedEventArgs 類別

定義

提供 TextChanged 事件的資料。

public ref class TextChangedEventArgs : System::Windows::RoutedEventArgs
public class TextChangedEventArgs : System.Windows.RoutedEventArgs
type TextChangedEventArgs = class
    inherit RoutedEventArgs
Public Class TextChangedEventArgs
Inherits RoutedEventArgs
繼承
TextChangedEventArgs

範例

下列範例會顯示變更中 TextBox 文字的次數。 以下是範例的 XAML 程式碼。

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
  x:Class="SDKSample.DetectChangedTextExample"
  Title="DetectChangedText">
  <StackPanel>
    <TextBox
      Name="tbCountingChanges"    
      TextChanged="textChangedEventHandler"
      TextWrapping="Wrap">
      Here is the initial text in the textbox.  Each time the contents of this box is changed, a change counter will
      be incremented and displayed in the TextBox below.  Note that the TextChanged event is called when the TextBox
      control is initially populated with text, so the changes counter starts of at 1.
    </TextBox>
    <TextBox Name="tbCounterText">0</TextBox>
    
  </StackPanel>  
</Page>

以下是此範例的程式碼後置。

using System.Windows.Controls;

namespace SDKSample
{
    public partial class DetectChangedTextExample : Page
    {
        // This is a counter for the number of times the TextChanged fires
        // for the tbCountingChanges TextBox.
        private int uiChanges = 0;

        // Event handler for TextChanged Event.
        private void textChangedEventHandler(object sender, TextChangedEventArgs args)
        {

            uiChanges++;
            if (tbCounterText != null)
            {
                tbCounterText.Text = uiChanges.ToString();
            }
        }
    }
}

Namespace SDKSample

    Partial Public Class DetectChangedTextExample
        Inherits Page

        ' This is a counter for the number of times the TextChanged fires
        ' for the tbCountingChanges TextBox.
        Private uiChanges As Integer = 0

        ' Event handler for TextChanged Event.
        Private Sub textChangedEventHandler(ByVal sender As Object,
                                            ByVal args As TextChangedEventArgs)

            uiChanges += 1
            If tbCounterText IsNot Nothing Then
                tbCounterText.Text = uiChanges.ToString()
            End If

        End Sub
    End Class
End Namespace

建構函式

TextChangedEventArgs(RoutedEvent, UndoAction)

使用指定的事件 ID 和復原動作,初始化 TextChangedEventArgs 類別的新執行個體。

TextChangedEventArgs(RoutedEvent, UndoAction, ICollection<TextChange>)

使用指定的事件 ID、復原動作和文字變更,初始化 TextChangedEventArgs 類別的新執行個體。

屬性

Changes

取得物件集合,此集合包含所發生變更的相關資訊。

Handled

取得或設定值,這個值表示路由事件在傳送路由時之事件處理的目前狀態。

(繼承來源 RoutedEventArgs)
OriginalSource

在父類別進行任何可能的 Source 調整之前,取得純點擊測試所判定的原始報告來源。

(繼承來源 RoutedEventArgs)
RoutedEvent

取得或設定與這個 RoutedEventArgs 執行個體相關聯的 RoutedEvent

(繼承來源 RoutedEventArgs)
Source

取得或設定引發事件之物件的參考。

(繼承來源 RoutedEventArgs)
UndoAction

了解導致復原堆疊的原因,或其受到文字變更影響的程度。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InvokeEventHandler(Delegate, Object)

執行適當的型別轉換,以呼叫 TextChangedEventHandler 事件的型別安全 TextChanged 委派。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnSetSource(Object)

在衍生類別中覆寫時,每當執行個體的 Source 屬性值變更,便會提供通知回呼進入點。

(繼承來源 RoutedEventArgs)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於