反馈异步加载数据时加载、反馈、数据

由网友(幸福靠双手打拼 ~)分享简介:我有一个组合框的的ItemsSource绑定到有IsAsynchronous属性设置为true的ObjectDataProvider。里面加载数据的方法,我把等待10秒,以模拟一个较长的加载时间这个数据。I have a ComboBox whose ItemsSource is bound to an Object...

我有一个组合框的的ItemsSource绑定到有IsAsynchronous属性设置为true的ObjectDataProvider。里面加载数据的方法,我把等待10秒,以模拟一个较长的加载时间这个数据。

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.

异步加载的伟大工程 - 整个窗口仍然响应,并在10秒后,我看到的组合框下拉列表填充

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

我想提醒,这种特定的组合框加载数据,期间有10秒钟的等待时间的用户。喜欢的东西在控制的背景进度,已启用只有当某种'isLoading财产或任何设置为true。是否有可能做到这一点?

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?

感谢。

推荐答案

这看起来像优先绑定可能是您的解决方案

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>

这里是一个很好的教程为优先绑定 HTTP://www.switchonthe$c$c.com/tutorials / WPF的教程优先级的绑定

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

或者看看MSDN 的http://msdn.microsoft.com/en-us/library/system.windows.data.prioritybinding.aspx

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

希望这有助于

阅读全文

相关推荐

最新文章