1

I have a ComboBox whose ItemsSource is bound to an ObjectDataProvider that has its IsAsynchronous property set to true. Inside the method that loads the data , I put a Wait for 10 seconds, to simulate a long loading time for this data.

The Asynchronous loading works great - the entire window is still responsive, and after 10 seconds I see the ComboBox dropdown populated.

I would like to alert the user that this specific ComboBox is loading data, during that 10 second wait time. Something like a progressBar in the background of the control, that is enabled only while a certain 'isLoading' property or whatever is set to true. Is it possible to accomplish this?

Thanks.

2 Answers 2

6

this looks like the Priority Binding could be a solution for you

<ListBox>
    <ListBox.ItemsSource>
    <PriorityBinding>
        <!-- highest priority sources are first in the list -->
        <Binding Path="LongLoadingCollection" IsAsync="True" />
        <!-- this contains only one item like "loading data..." -->
        <Binding Path="LoadMessage" IsAsync="True" />
    </PriorityBinding>
    </ListBox.ItemsSource>
</ListBox>

enter image description here

here is an good tutorial for Priority Bindings
http://www.switchonthecode.com/tutorials/wpf-tutorial-priority-bindings

or take a look at msdn
http://msdn.microsoft.com/en-us/library/system.windows.data.prioritybinding.aspx

hope this helps

Sign up to request clarification or add additional context in comments.

1 Comment

Please try to make your answer stand on its own, off-site links can be useful but they tend to die, if you link off-site see if the official documentation sufficient, it is to be preferred to some random blog, and if the official documentation is gone the technology it documented probably is too: PriorityBinding
0

It doesn't appear that the ObjectDataProvider has any properties to say when it is and isn't retrieving data.

It depends on your architecture, but you could expose properties that give a "load state" to your object that contains the method that loads the data. Then you could bind a progress bar or other "Please Wait..." kind of UI to that new state property.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.