How to apply Search in Editable Combobox in WPF using MVVM












1















I have editable combobox in WPF. which is having list of order number.
I need to implement below scenario in my code.
The user can fill the starting of order number, and, the system propose the close order number available in the dropdown list.



Can anyone suggest how to do that?



In My Viewmodel i have written:



        public void _fillREOrderNumbers()   
{
List<FinishedReprintingOrderNumber> orders = _finishedProductReprintService.GetFinishedProductReprintbyOrder().ToList();
foreach (var item in orders)
{
ReOrders.Add(item);
}
}


This is loading the order number in drop down.



View or XAML:



<ComboBox x:Name="cbOFab" HorizontalAlignment="Left" Margin="373,81,0,0" 
VerticalAlignment="Top" Width="262" IsEditable="True"
ItemsSource="{Binding ReOrders, Mode=TwoWay}" DisplayMemberPath="codOrder" SelectedItem="{Binding
ReSelectedOrder}" Background="{DynamicResource dgridRowColor}" />


Till Now,
I am able to populate the order number in my combo box but I am not aware how to search inside it.










share|improve this question

























  • stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf

    – Iti Tyagi
    Aug 6 '18 at 10:33













  • Possible duplicate of AutoComplete TextBox in WPF

    – Anton Gorbunov
    Aug 6 '18 at 10:46











  • I need to use ComboBOX instead of TextBox..

    – Naman
    Aug 6 '18 at 11:00











  • You are probably looking for IsTextSearchEnabled="True"

    – Kaspar
    Aug 6 '18 at 12:09











  • kaspar: I want my combobox will display the order number which is entered by user. Not full list which is being selected.

    – Naman
    Aug 6 '18 at 12:18
















1















I have editable combobox in WPF. which is having list of order number.
I need to implement below scenario in my code.
The user can fill the starting of order number, and, the system propose the close order number available in the dropdown list.



Can anyone suggest how to do that?



In My Viewmodel i have written:



        public void _fillREOrderNumbers()   
{
List<FinishedReprintingOrderNumber> orders = _finishedProductReprintService.GetFinishedProductReprintbyOrder().ToList();
foreach (var item in orders)
{
ReOrders.Add(item);
}
}


This is loading the order number in drop down.



View or XAML:



<ComboBox x:Name="cbOFab" HorizontalAlignment="Left" Margin="373,81,0,0" 
VerticalAlignment="Top" Width="262" IsEditable="True"
ItemsSource="{Binding ReOrders, Mode=TwoWay}" DisplayMemberPath="codOrder" SelectedItem="{Binding
ReSelectedOrder}" Background="{DynamicResource dgridRowColor}" />


Till Now,
I am able to populate the order number in my combo box but I am not aware how to search inside it.










share|improve this question

























  • stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf

    – Iti Tyagi
    Aug 6 '18 at 10:33













  • Possible duplicate of AutoComplete TextBox in WPF

    – Anton Gorbunov
    Aug 6 '18 at 10:46











  • I need to use ComboBOX instead of TextBox..

    – Naman
    Aug 6 '18 at 11:00











  • You are probably looking for IsTextSearchEnabled="True"

    – Kaspar
    Aug 6 '18 at 12:09











  • kaspar: I want my combobox will display the order number which is entered by user. Not full list which is being selected.

    – Naman
    Aug 6 '18 at 12:18














1












1








1








I have editable combobox in WPF. which is having list of order number.
I need to implement below scenario in my code.
The user can fill the starting of order number, and, the system propose the close order number available in the dropdown list.



Can anyone suggest how to do that?



In My Viewmodel i have written:



        public void _fillREOrderNumbers()   
{
List<FinishedReprintingOrderNumber> orders = _finishedProductReprintService.GetFinishedProductReprintbyOrder().ToList();
foreach (var item in orders)
{
ReOrders.Add(item);
}
}


This is loading the order number in drop down.



View or XAML:



<ComboBox x:Name="cbOFab" HorizontalAlignment="Left" Margin="373,81,0,0" 
VerticalAlignment="Top" Width="262" IsEditable="True"
ItemsSource="{Binding ReOrders, Mode=TwoWay}" DisplayMemberPath="codOrder" SelectedItem="{Binding
ReSelectedOrder}" Background="{DynamicResource dgridRowColor}" />


Till Now,
I am able to populate the order number in my combo box but I am not aware how to search inside it.










share|improve this question
















I have editable combobox in WPF. which is having list of order number.
I need to implement below scenario in my code.
The user can fill the starting of order number, and, the system propose the close order number available in the dropdown list.



Can anyone suggest how to do that?



In My Viewmodel i have written:



        public void _fillREOrderNumbers()   
{
List<FinishedReprintingOrderNumber> orders = _finishedProductReprintService.GetFinishedProductReprintbyOrder().ToList();
foreach (var item in orders)
{
ReOrders.Add(item);
}
}


This is loading the order number in drop down.



View or XAML:



<ComboBox x:Name="cbOFab" HorizontalAlignment="Left" Margin="373,81,0,0" 
VerticalAlignment="Top" Width="262" IsEditable="True"
ItemsSource="{Binding ReOrders, Mode=TwoWay}" DisplayMemberPath="codOrder" SelectedItem="{Binding
ReSelectedOrder}" Background="{DynamicResource dgridRowColor}" />


Till Now,
I am able to populate the order number in my combo box but I am not aware how to search inside it.







c# wpf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 6 '18 at 10:11









Prashant Pimpale

3,1433830




3,1433830










asked Aug 6 '18 at 10:06









NamanNaman

117




117













  • stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf

    – Iti Tyagi
    Aug 6 '18 at 10:33













  • Possible duplicate of AutoComplete TextBox in WPF

    – Anton Gorbunov
    Aug 6 '18 at 10:46











  • I need to use ComboBOX instead of TextBox..

    – Naman
    Aug 6 '18 at 11:00











  • You are probably looking for IsTextSearchEnabled="True"

    – Kaspar
    Aug 6 '18 at 12:09











  • kaspar: I want my combobox will display the order number which is entered by user. Not full list which is being selected.

    – Naman
    Aug 6 '18 at 12:18



















  • stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf

    – Iti Tyagi
    Aug 6 '18 at 10:33













  • Possible duplicate of AutoComplete TextBox in WPF

    – Anton Gorbunov
    Aug 6 '18 at 10:46











  • I need to use ComboBOX instead of TextBox..

    – Naman
    Aug 6 '18 at 11:00











  • You are probably looking for IsTextSearchEnabled="True"

    – Kaspar
    Aug 6 '18 at 12:09











  • kaspar: I want my combobox will display the order number which is entered by user. Not full list which is being selected.

    – Naman
    Aug 6 '18 at 12:18

















stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf

– Iti Tyagi
Aug 6 '18 at 10:33







stackoverflow.com/questions/950770/autocomplete-textbox-in-wpf

– Iti Tyagi
Aug 6 '18 at 10:33















Possible duplicate of AutoComplete TextBox in WPF

– Anton Gorbunov
Aug 6 '18 at 10:46





Possible duplicate of AutoComplete TextBox in WPF

– Anton Gorbunov
Aug 6 '18 at 10:46













I need to use ComboBOX instead of TextBox..

– Naman
Aug 6 '18 at 11:00





I need to use ComboBOX instead of TextBox..

– Naman
Aug 6 '18 at 11:00













You are probably looking for IsTextSearchEnabled="True"

– Kaspar
Aug 6 '18 at 12:09





You are probably looking for IsTextSearchEnabled="True"

– Kaspar
Aug 6 '18 at 12:09













kaspar: I want my combobox will display the order number which is entered by user. Not full list which is being selected.

– Naman
Aug 6 '18 at 12:18





kaspar: I want my combobox will display the order number which is entered by user. Not full list which is being selected.

– Naman
Aug 6 '18 at 12:18












1 Answer
1






active

oldest

votes


















0














I have implemented filtering of items in ComboBox this way.



Here is XAML:



<ComboBox
MinWidth="200"
ItemsSource="{Binding Path=Shops.View, RelativeSource={RelativeSource TemplatedParent}}"
DisplayMemberPath="NameExtended"
SelectedItem="{Binding Path=SelectedShop, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsTextSearchEnabled="False"
IsEditable="True"
IsDropDownOpen="{Binding Path=ComboOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
StaysOpenOnEdit="True"
Text="{Binding Path=SearchText, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
>
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp">
<i:InvokeCommandAction
Command="{Binding Path=FilterCommand, RelativeSource={RelativeSource TemplatedParent}}"
/>
</i:EventTrigger>
</i:Interaction.Triggers>




You need all lines from IsTextSearchEnabled and below.



When you press any key in combo box, it opens in up and filters items in it, using property SearchText bound to ComboBox.Text.



Here is the view model code:



public string SearchText { get; set; }
private List<Shop> _shops;

protected void FilterShops()
{
ComboOpen = true;
if (!string.IsNullOrEmpty(SearchText))
{
Shops.UpdateSource(_shops.Where(s => s.NameExtended.ToLower().Contains(SearchText.ToLower())));
}
else
{
Shops.UpdateSource(_shops);
}
OnPropertyChanged("Shops");
}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51705153%2fhow-to-apply-search-in-editable-combobox-in-wpf-using-mvvm%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I have implemented filtering of items in ComboBox this way.



    Here is XAML:



    <ComboBox
    MinWidth="200"
    ItemsSource="{Binding Path=Shops.View, RelativeSource={RelativeSource TemplatedParent}}"
    DisplayMemberPath="NameExtended"
    SelectedItem="{Binding Path=SelectedShop, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
    IsTextSearchEnabled="False"
    IsEditable="True"
    IsDropDownOpen="{Binding Path=ComboOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
    StaysOpenOnEdit="True"
    Text="{Binding Path=SearchText, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
    >
    <i:Interaction.Triggers>
    <i:EventTrigger EventName="KeyUp">
    <i:InvokeCommandAction
    Command="{Binding Path=FilterCommand, RelativeSource={RelativeSource TemplatedParent}}"
    />
    </i:EventTrigger>
    </i:Interaction.Triggers>




    You need all lines from IsTextSearchEnabled and below.



    When you press any key in combo box, it opens in up and filters items in it, using property SearchText bound to ComboBox.Text.



    Here is the view model code:



    public string SearchText { get; set; }
    private List<Shop> _shops;

    protected void FilterShops()
    {
    ComboOpen = true;
    if (!string.IsNullOrEmpty(SearchText))
    {
    Shops.UpdateSource(_shops.Where(s => s.NameExtended.ToLower().Contains(SearchText.ToLower())));
    }
    else
    {
    Shops.UpdateSource(_shops);
    }
    OnPropertyChanged("Shops");
    }





    share|improve this answer




























      0














      I have implemented filtering of items in ComboBox this way.



      Here is XAML:



      <ComboBox
      MinWidth="200"
      ItemsSource="{Binding Path=Shops.View, RelativeSource={RelativeSource TemplatedParent}}"
      DisplayMemberPath="NameExtended"
      SelectedItem="{Binding Path=SelectedShop, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
      IsTextSearchEnabled="False"
      IsEditable="True"
      IsDropDownOpen="{Binding Path=ComboOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
      StaysOpenOnEdit="True"
      Text="{Binding Path=SearchText, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
      >
      <i:Interaction.Triggers>
      <i:EventTrigger EventName="KeyUp">
      <i:InvokeCommandAction
      Command="{Binding Path=FilterCommand, RelativeSource={RelativeSource TemplatedParent}}"
      />
      </i:EventTrigger>
      </i:Interaction.Triggers>




      You need all lines from IsTextSearchEnabled and below.



      When you press any key in combo box, it opens in up and filters items in it, using property SearchText bound to ComboBox.Text.



      Here is the view model code:



      public string SearchText { get; set; }
      private List<Shop> _shops;

      protected void FilterShops()
      {
      ComboOpen = true;
      if (!string.IsNullOrEmpty(SearchText))
      {
      Shops.UpdateSource(_shops.Where(s => s.NameExtended.ToLower().Contains(SearchText.ToLower())));
      }
      else
      {
      Shops.UpdateSource(_shops);
      }
      OnPropertyChanged("Shops");
      }





      share|improve this answer


























        0












        0








        0







        I have implemented filtering of items in ComboBox this way.



        Here is XAML:



        <ComboBox
        MinWidth="200"
        ItemsSource="{Binding Path=Shops.View, RelativeSource={RelativeSource TemplatedParent}}"
        DisplayMemberPath="NameExtended"
        SelectedItem="{Binding Path=SelectedShop, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
        IsTextSearchEnabled="False"
        IsEditable="True"
        IsDropDownOpen="{Binding Path=ComboOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
        StaysOpenOnEdit="True"
        Text="{Binding Path=SearchText, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
        >
        <i:Interaction.Triggers>
        <i:EventTrigger EventName="KeyUp">
        <i:InvokeCommandAction
        Command="{Binding Path=FilterCommand, RelativeSource={RelativeSource TemplatedParent}}"
        />
        </i:EventTrigger>
        </i:Interaction.Triggers>




        You need all lines from IsTextSearchEnabled and below.



        When you press any key in combo box, it opens in up and filters items in it, using property SearchText bound to ComboBox.Text.



        Here is the view model code:



        public string SearchText { get; set; }
        private List<Shop> _shops;

        protected void FilterShops()
        {
        ComboOpen = true;
        if (!string.IsNullOrEmpty(SearchText))
        {
        Shops.UpdateSource(_shops.Where(s => s.NameExtended.ToLower().Contains(SearchText.ToLower())));
        }
        else
        {
        Shops.UpdateSource(_shops);
        }
        OnPropertyChanged("Shops");
        }





        share|improve this answer













        I have implemented filtering of items in ComboBox this way.



        Here is XAML:



        <ComboBox
        MinWidth="200"
        ItemsSource="{Binding Path=Shops.View, RelativeSource={RelativeSource TemplatedParent}}"
        DisplayMemberPath="NameExtended"
        SelectedItem="{Binding Path=SelectedShop, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
        IsTextSearchEnabled="False"
        IsEditable="True"
        IsDropDownOpen="{Binding Path=ComboOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
        StaysOpenOnEdit="True"
        Text="{Binding Path=SearchText, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
        >
        <i:Interaction.Triggers>
        <i:EventTrigger EventName="KeyUp">
        <i:InvokeCommandAction
        Command="{Binding Path=FilterCommand, RelativeSource={RelativeSource TemplatedParent}}"
        />
        </i:EventTrigger>
        </i:Interaction.Triggers>




        You need all lines from IsTextSearchEnabled and below.



        When you press any key in combo box, it opens in up and filters items in it, using property SearchText bound to ComboBox.Text.



        Here is the view model code:



        public string SearchText { get; set; }
        private List<Shop> _shops;

        protected void FilterShops()
        {
        ComboOpen = true;
        if (!string.IsNullOrEmpty(SearchText))
        {
        Shops.UpdateSource(_shops.Where(s => s.NameExtended.ToLower().Contains(SearchText.ToLower())));
        }
        else
        {
        Shops.UpdateSource(_shops);
        }
        OnPropertyChanged("Shops");
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 14:21









        Eugene RozhkovEugene Rozhkov

        58358




        58358






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51705153%2fhow-to-apply-search-in-editable-combobox-in-wpf-using-mvvm%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            Refactoring coordinates for Minecraft Pi buildings written in Python