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)

适用于