Binding data on demand in WPF RRS feed

  • Question

  • Hi All,

    I am using a combobox in a window and it’s itemsSource Property is binded to a property called list.

    Now the problem is , when combobox is initializing itemssource is getting data from list property (because I have binded). I want when first time combobox’s popup is open then it should retrieve data from list property. Not at time of combobox initialzing.

    In my window there are nearly 10 comboxbox and every combobox is getting data from database at the time of windown loading so window loading is getting slow. So I want data should retrieve when popup is open or getting first time focus on  combobox.

    Prem Shah

    Wednesday, July 31, 2013 5:38 AM


  • How about you don't set binding at loading time but you listen to combobox popup menu opened event and then you set the binding?

    I haven't tested it out but it might work. At least it's an idea of how to control when to create or remove binding.

    The combobox popup menu opened event will inform you about sender which is a combobox and about pop up event args. You can use sender information to create or change binding at runtime. You can use just one method in codebehind and each combobox listens to that method. Once any combobox opens it's pop up menu the method will get called and you will be able to create or remove binding for that certain combobox inside the method.

    Wednesday, July 31, 2013 6:31 AM