Coder Social home page Coder Social logo

aigt / dotnetkit.wpf.autocompletecombobox Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vain0x/dotnetkit.wpf.autocompletecombobox

0.0 0.0 0.0 1.26 MB

ComboBox with filtering (auto-complete) for WPF

License: MIT License

C# 99.79% PowerShell 0.21%

dotnetkit.wpf.autocompletecombobox's Introduction

AutoCompleteComboBox for WPF

NuGet version

Provides a lightweight combobox with filtering (auto-complete).

Screenshot

Usage

Install via NuGet.

Declare XML namespace.

<Window
    ...
    xmlns:dotNetKitControls="clr-namespace:DotNetKit.Windows.Controls;assembly=DotNetKit.Wpf.AutoCompleteComboBox"
    ... >

Then you can use AutoCompleteComboBox. It's like a normal ComboBox because of inheritance.

<dotNetKitControls:AutoCompleteComboBox
    SelectedValuePath="Id"
    TextSearch.TextPath="Name"
    ItemsSource="{Binding Items}"
    SelectedItem="{Binding SelectedItem}"
    SelectedValue="{Binding SelectedValue}"
    />

Note that:

  • Set a property path to TextSearch.TextPath property.
    • The path leads to a property whose getter produces a string value to identify items. For example, assume each item is an instance of Person, which has Name property, and the property path is "Name". If the user input "va", the combobox filters the items to remove ones (persons) whose Name don't contain "va".
    • No support for TextSeach.Text.
  • Don't use ComboBox.Items property directly. Use ItemsSource instead.
  • Although the Demo project uses DataTemplate to display items, you can also use DisplayMemberPath.

Configuration

This library works fine in the default setting, however, it also provides how to configure.

<dotNetKitControls:AutoCompleteComboBox
    Setting="..."
    ...
    />
  • Or set to AutoCompleteComboBoxSetting.Default to apply to all comboboxes.

Performance

Filtering allows you to add a lot of items to a combobox without loss of usability, however, that makes the performance poor. To get rid of the issue, we recommend you to use VirtualizingStackPanel as the panel.

Use ItemsPanel property:

<dotNetKitControls:AutoCompleteComboBox ...>
    <dotNetKitControls:AutoCompleteComboBox.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
    </dotNetKitControls:AutoCompleteComboBox.ItemsPanel>
</dotNetKitControls:AutoCompleteComboBox>

or declare a style in resources as the Demo app does.

See also WPF: Using a VirtualizingStackPanel to Improve ComboBox Performance for more detailed explanation.

dotnetkit.wpf.autocompletecombobox's People

Contributors

vain0x avatar croddin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.