TextSearch 类

定义

使用户能够通过键入字符串的前缀来快速访问组中的项。Enables a user to quickly access items in a set by typing prefixes of strings.

public ref class TextSearch sealed : System::Windows::DependencyObject
public sealed class TextSearch : System.Windows.DependencyObject
type TextSearch = class
    inherit DependencyObject
Public NotInheritable Class TextSearch
Inherits DependencyObject
继承

示例

下面的示例创建ComboBox包含图像的控件, 而不是文本。The following examples create ComboBox controls that contain images as items instead of text. 在功能上, 示例是相同的。Functionally, the examples are the same. 第一个示例设置TextPath ComboBox上的属性, 第二个示例设置集合Text中每个项的属性。The first example sets the TextPath property on the ComboBox and the second example sets the Text property on each item in the collection.

<ComboBox IsEditable="true" TextSearch.TextPath="Name">
  <Image Name="Cat" Source="data\cat.png"/>
  <Image Name="Dog" Source="data\dog.png"/>
  <Image Name="Fish" Source="data\fish.png"/>
</ComboBox>
<ComboBox IsEditable="true">
  <Image TextSearch.Text="Cat" Source="data\cat.png"/>
  <Image TextSearch.Text="Dog" Source="data\dog.png"/>
  <Image TextSearch.Text="Fish" Source="data\fish.png"/>
</ComboBox>

注解

此类用于将字符串分配给控件的集合中的项。This class is used to assign a string to items in a control's collection. 为集合中的每个项分配一个字符串可以完成两个目标。Assigning a string to each item in the collection accomplishes two objectives. 它指定在选择项时要显示的文本, 并允许用户通过键入指定的字符串来选择项。It specifies the text to display when the item is selected, and it enables the user to select an item by typing the assigned string.

例如, 假设ComboBox包含一个Image对象集合, 其中一个对象是狗的图像。For example, assume that a ComboBox contains a collection of Image objects, one of which is an image of a dog. 如果将字符串 "Dog" 分配给该项, 则用户可以通过在组合框的文本框中键入字词来选择狗。If you assign the string, "Dog" to that item, the user can select the dog by typing the word in the combo box's text box. 一旦用户键入了足以与选定内容中的其他项区分的字, 就会选择狗的图像。As soon as the user types enough of the word to distinguish it from other items in the selection, the image of the dog will be selected. 如果IsEditable将设置为true ComboBox, 则 "狗" 将出现在文本框中。If IsEditable is set to true on the ComboBox, "Dog" will appear in the text box.

通过使用控件上的TextSearch.TextPath属性或在控件的集合中的每一项上Text设置属性, 可以指定标识该项的文本。You can specify the text that identifies an item by using the TextSearch.TextPath property on a control or by setting the Text property on each item in the control's collection. 设置这些属性之一可确保不显示意外文本。Setting one of these properties ensures that unexpected text is not displayed. 如果在控件的Text收集项上设置属性, 则将忽略TextPath该属性。If you set the Text property on a control's collection item, the TextPath property will be ignored. 如果将TextPath属性设置为不是实际属性名称的值, TextPath则将忽略。If you set the TextPath property to a value that is not the name of an actual property, TextPath is ignored.

XAML 文本用法XAML Text Usage

你不能在中XAMLXAML声明此托管类, 但可以使用其静态属性在中XAMLXAML分配值。You cannot declare this managed class in XAMLXAML, but you can use its static properties to assign values in XAMLXAML.

字段

TextPathProperty

标识 TextPath 附加属性。Identifies the TextPath attached property.

TextProperty

标识 Text 附加属性。Identifies the Text attached property.

属性

DependencyObjectType

获取对此实例的 CLRCLR 类型进行包装的 DependencyObjectTypeGets the DependencyObjectType that wraps the CLRCLR type of this instance.

(继承自 DependencyObject)
Dispatcher

获取与此 Dispatcher 关联的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(继承自 DispatcherObject)
IsSealed

获取一个值,该值指示此实例当前是否为密封的(只读)。Gets a value that indicates whether this instance is currently sealed (read-only).

(继承自 DependencyObject)

附加属性

Text

获取或设置一个字符串,该字符串标识控件的集合中的某个项。Gets or sets the string that identifies an item in a control's collection.

TextPath

获取或设置标识控件集合中的每一项的项属性的名称。Gets or sets the name of the items' property that identifies each item in a control's collection.

方法

CheckAccess()

确定调用线程是否可以访问此 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(继承自 DispatcherObject)
ClearValue(DependencyProperty)

清除属性的本地值。Clears the local value of a property. 要清除的属性由 DependencyProperty 标识符指定。The property to be cleared is specified by a DependencyProperty identifier.

(继承自 DependencyObject)
ClearValue(DependencyPropertyKey)

清除只读属性的本地值。Clears the local value of a read-only property. 要清除的属性由 DependencyPropertyKey 指定。The property to be cleared is specified by a DependencyPropertyKey.

(继承自 DependencyObject)
CoerceValue(DependencyProperty)

对指定依赖属性的值进行强制。Coerces the value of the specified dependency property. 通过对调用方 DependencyObject 上存在的依赖属性的属性元数据中所指定的任何 CoerceValueCallback 函数进行调用来完成此操作。This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.

(继承自 DependencyObject)
Equals(Object)

确定提供的 DependencyObject 是否等效于当前 DependencyObjectDetermines whether a provided DependencyObject is equivalent to the current DependencyObject.

(继承自 DependencyObject)
GetHashCode()

获取此 DependencyObject 的哈希代码。Gets a hash code for this DependencyObject.

(继承自 DependencyObject)
GetLocalValueEnumerator()

创建一个专用的枚举数,用于确定哪些依赖项属性在此 DependencyObject 上具有以本地方式设置的值。Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.

(继承自 DependencyObject)
GetText(DependencyObject)

返回标识指定项的字符串。Returns the string to that identifies the specified item.

GetTextPath(DependencyObject)

返回属性的名称,该属性标识指定元素的集合中的项。Returns the name of the property that identifies an item in the specified element's collection.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetValue(DependencyProperty)

DependencyObject 的此实例返回依赖属性的当前有效值。Returns the current effective value of a dependency property on this instance of a DependencyObject.

(继承自 DependencyObject)
InvalidateProperty(DependencyProperty)

重新评估指定依赖属性的有效值。Re-evaluates the effective value for the specified dependency property.

(继承自 DependencyObject)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnPropertyChanged(DependencyPropertyChangedEventArgs)

每当更新此 DependencyObject 的任何依赖属性的有效值时调用。Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. 更改的特定依赖属性将在事件数据中报告。The specific dependency property that changed is reported in the event data.

(继承自 DependencyObject)
ReadLocalValue(DependencyProperty)

如果存在,则返回依赖属性的本地值。Returns the local value of a dependency property, if it exists.

(继承自 DependencyObject)
SetCurrentValue(DependencyProperty, Object)

设置依赖属性的值而不更改其值源。Sets the value of a dependency property without changing its value source.

(继承自 DependencyObject)
SetText(DependencyObject, String)

Text 附加属性值写入指定元素。Writes the Text attached property value to the specified element.

SetTextPath(DependencyObject, String)

TextPath 附加属性写入指定元素。Writes the TextPath attached property to the specified element.

SetValue(DependencyProperty, Object)

设置依赖属性的本地值,该值由其依赖属性标识符指定。Sets the local value of a dependency property, specified by its dependency property identifier.

(继承自 DependencyObject)
SetValue(DependencyPropertyKey, Object)

设置一个只读依赖属性的本地值,该值由依赖属性的 DependencyPropertyKey 标识符指定。Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.

(继承自 DependencyObject)
ShouldSerializeProperty(DependencyProperty)

返回一个值,该值指示序列化进程是否应序列化所提供的依赖属性的值。Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.

(继承自 DependencyObject)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
VerifyAccess()

强制调用线程具有此 DispatcherObject 的访问权限。Enforces that the calling thread has access to this DispatcherObject.

(继承自 DispatcherObject)

适用于

另请参阅