Reputation: 9252
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.
Upvotes: 1
Views: 1004
Reputation: 14611
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>
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
Upvotes: 6
Reputation: 15237
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.
Upvotes: 0