Xceed Toolkit for .NET Maui v2.0 Documentation
Xceed.Maui.Toolkit Assembly / Xceed.Maui.Toolkit Namespace / AutoCompleteTextBox Class / CustomFilterAction Property
Example


In This Topic
    CustomFilterAction Property (AutoCompleteTextBox)
    In This Topic
    Gets or sets a custom filter that filters the ItemsSource while text is being typed in the AutoCompleteTextBox.
    Syntax
    'Declaration
     
    
    Public Property CustomFilterAction As ICustomFilterAction
    'Usage
     
    
    Dim instance As AutoCompleteTextBox
    Dim value As ICustomFilterAction
     
    instance.CustomFilterAction = value
     
    value = instance.CustomFilterAction
    public ICustomFilterAction CustomFilterAction {get; set;}
    Remarks

    The value of this property represents a class that derives from ICustomFilterAction & implements its IsItemPassFilter method, which will be called as the ItemsSource is being filtered.

    Note that the AutoCompleteTextBox's FilterType property must be set to Custom in order to use the CustomFilterAction property.

    Example

    In the following example, every time a new character is typed, every item of the AutoCompleteTextBox will call the IsItemPassFilter method.

    Only the items containing two instances of the characters typed in the TextBox will pass the filter & be displayed in the AutoCompleteTextBox. This means that if the letter "a" is typed, only the words containing two instances of "a" will be displayed.

    _autoCompleteTextBox.CustomFilterAction = new MyCustomFilterAction();
    
    public class MyCustomFilterAction : ICustomFilterAction
    {
      public bool IsItemPassFilter( object item, string filterText )
      {
        return ( (string)item ).Count( x => char.ToLower( x ) == filterText.ToLower()[ 0 ] ) == 2;
      }
    }
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also