TextSearch 類別

定義

讓使用者能透過輸入字串前置字元,快速存取集合中的項目。

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 控制項,其中包含影像做為專案,而不是文字。 在功能上,範例相同。 第一個範例會在 TextPathComboBox 設定 屬性,而第二個範例會在集合中的每個專案上設定 Text 屬性。

<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>

備註

這個類別可用來將字串指派給控制項集合中的專案。 將字串指派給集合中的每個專案會完成兩個目標。 它會指定要在選取專案時顯示的文字,並讓使用者輸入指派的字串來選取專案。

例如,假設 ComboBox 包含 物件的集合 Image ,其中一個是狗的影像。 如果您將字串 「Dog」 指派給該專案,使用者可以在下拉式方塊的文字方塊中輸入字來選取狗。 一旦使用者輸入足夠的字組來區分選取範圍中的其他專案,就會選取狗的影像。 如果 IsEditable 設定 true 為 上的 ComboBox ,則 「Dog」 會出現在文字方塊中。

您可以使用 控制項上的 屬性,或在控制項集合中的每個專案上設定 Text 屬性,來指定識別專案的 TextSearch.TextPath 文字。 設定其中一個屬性可確保不會顯示非預期的文字。 如果您在控制項的集合專案上設定 Text 屬性, TextPath 則會忽略 屬性。 如果您將 TextPath 屬性設定為不是實際屬性名稱的值, TextPath 則會忽略。

XAML 文字使用方式

您無法在 XAML 中宣告這個 Managed 類別,但您可以使用其靜態屬性在 XAML 中指派值。

欄位

TextPathProperty

識別 TextPath 附加屬性。

TextProperty

識別 Text 附加屬性。

屬性

DependencyObjectType

取得包裝 DependencyObjectType 這個實例 CLR 型別的 。

(繼承來源 DependencyObject)
Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObject

(繼承來源 DispatcherObject)
IsSealed

取得值,這個值表示此執行個體目前是否已密封 (唯讀)。

(繼承來源 DependencyObject)

附加屬性

Text

取得或設定識別控制項集合中項目的字串。

TextPath

取得或設定可識別控制項集合中每個項目的項目屬性名稱。

方法

CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObject

(繼承來源 DispatcherObject)
ClearValue(DependencyProperty)

清除屬性的區域數值。 要清除的屬性是由 DependencyProperty 識別項所指定。

(繼承來源 DependencyObject)
ClearValue(DependencyPropertyKey)

清除唯讀屬性的區域數值。 要清除的屬性是由 DependencyPropertyKey 所指定。

(繼承來源 DependencyObject)
CoerceValue(DependencyProperty)

強制轉型所指定相依性屬性的值。 完成方式是叫用存在於呼叫 DependencyObject 之相依性屬性的屬性中繼資料中所指定的任何 CoerceValueCallback 函式。

(繼承來源 DependencyObject)
Equals(Object)

判斷提供的 DependencyObject 和目前的 DependencyObject 是否相等。

(繼承來源 DependencyObject)
GetHashCode()

取得這個 DependencyObject 的雜湊碼。

(繼承來源 DependencyObject)
GetLocalValueEnumerator()

建立特定的列舉值,以判斷哪些相依性屬性在此 DependencyObject 上具有本機設定的值。

(繼承來源 DependencyObject)
GetText(DependencyObject)

傳回識別指定項目的字串。

GetTextPath(DependencyObject)

傳回識別指定項目 (element) 集合中之項目 (item) 的屬性名稱。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetValue(DependencyProperty)

傳回 DependencyObject 的這個執行個體上之相依性屬性的目前有效值。

(繼承來源 DependencyObject)
InvalidateProperty(DependencyProperty)

重新評估指定相依性屬性的有效值。

(繼承來源 DependencyObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
OnPropertyChanged(DependencyPropertyChangedEventArgs)

每當這個 DependencyObject 上任何相依性屬性的有效值已更新時叫用。 已變更的特定相依性屬性會在事件資料中報告。

(繼承來源 DependencyObject)
ReadLocalValue(DependencyProperty)

傳回相依性屬性的區域值 (如果存在)。

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

設定相依性屬性的值,而不需要變更其值來源。

(繼承來源 DependencyObject)
SetText(DependencyObject, String)

Text 附加屬性值寫入指定的項目。

SetTextPath(DependencyObject, String)

TextPath 附加屬性寫入指定的項目。

SetValue(DependencyProperty, Object)

設定相依性屬性的區域值 (由相依性屬性的識別碼所指定)。

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

設定唯讀相依性屬性的區域數值 (由相依性屬性的 DependencyPropertyKey 識別項所指定)。

(繼承來源 DependencyObject)
ShouldSerializeProperty(DependencyProperty)

傳回值,這個值表示序列化程序是否應該序列化所提供相依性屬性的值。

(繼承來源 DependencyObject)
ToString()

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

(繼承來源 Object)
VerifyAccess()

請強制執行可以存取這個 DispatcherObject 的呼叫執行緒。

(繼承來源 DispatcherObject)

適用於

另請參閱