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


In This Topic
    CustomFilterAction Property (ComboBox)
    In This Topic
    Gets or sets a custom filter that will filter the ItemsSource while text is being typed in the ComboBox.
    Syntax
    'Declaration
     
    
    Public Property CustomFilterAction As ICustomFilterAction
    'Usage
     
    
    Dim instance As ComboBox
    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 ComboBox's FilterType property must be set to Custom in order to use this property. 

    Example

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

    Only the items that start with the characters typed in the ComboBox will pass the filter & be displayed in the Popup. This means that if the characters "C" & "A" are typed in the ComboBox, the ItemsSource will be filtered so that only the items that start with "CA" are displayed in the ComboBox's Popup.

    var newCustomFilterAction = new MyComboBoxCustomFilterAction();
    comboBox.CustomFilterAction = newCustomFilterAction;
    
    private class MyComboBoxCustomFilterAction : ICustomFilterAction
    {
      public bool IsItemPassFilter( object item, string filterText )
      { 
        return (( string )item).StartsWith( filterText );
      }
    }
    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