Thursday, 28 June 2018

Auto Complete Incremental Search with ReactiveUI ?

A Winforms UserControl had an incremental search TextBox and a list. A detail view is set from the selected value in the list. This works when I click on a particular list item.

I want to get the last string value from the incremental AutoCompleteSearch TextBox too. To fire a command and also set the user in the Detail view. But:

 Couldn't find a Command Binder for System.Windows.Forms.AutoCompleteStringCollection 

listUsers is the compound UserControl with a property SearchAutoCompleteCustomSource:

    public AutoCompleteStringCollection SearchAutoCompleteCustomSource
        get { return tbAutoCompleteSearch.AutoCompleteCustomSource; }
        set { tbAutoCompleteSearch.AutoCompleteCustomSource = value; }


    this.BindCommand(this.ViewModel, vm => vm.UserToFind,
                                      v => v.listUsers.SearchAutoCompleteCustomSource);


private readonly ReactiveCommand userToFind;
public ReactiveCommand UserToFind => this.userToFind;

public MyViewModel()
    this.userToFind = ReactiveCommand.Create(userName => this.SetUserSelected(userName));

private bool SetUserSelected(string userName)
    User user = userManager.GetUserByName(userName);
    bool userFound = (user != null);

    if (userFound)
    return userFound;

No comments:

Post a Comment