项目组合框装事件WPF?

编程入门 行业动态 更新时间:2024-10-28 18:31:06
本文介绍了项目组合框装事件WPF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经有通过的ItemsSource绑定设置为一个ObservableCollection属性调用数据的组合框。这份名单具有巨大的数据,所以还需要一段时间组合框中完全加载的所有项目。

I have a combobox which has ItemsSource set to an ObservableCollection property called DATA via binding. This list has huge data so it will take some time for the combo box to fully load all the items.

我有一个后台工作,获取所有的信息并在完成后设置的ObservableCollection特性数据。当发生这种情况我显示进度指示器,然而,当我设置的ObservableCollection数据UI似乎仍然挂相当长一段时间,然后在下拉被装起来会的所有项目。

I have a background worker that gets all info and sets the ObservableCollection property DATA when done. While this is happening I show a progress indicator, However, after I set the ObservableCollection DATA the UI still seems to hang for quite a while and then the combobox gets loaded up will all items.

是否有组合框,让我知道,当所有的项目都在UI被正确呈现一个事件?

Is there an event on combobox that lets me know when all the items have been correctly rendered in the UI?

感谢

推荐答案

您可以使用以下code作为参考,这里的进度条和搜索都在同一个线程中运行,与调度员正在被用来notifiy用户界面:

You can use the following code as reference, and here the progress bar and search both are running in same thread, and Dispatcher is being used to notifiy the UI:

DoWorkEventHandler workHandler = null; RunWorkerCompletedEventHandler doneHandler = null; Action<parameters> actionCompleted = null; BackgroundWorker worker = new BackgroundWorker(); worker.DoWork += workHandler = delegate ( object oDoWrk, DoWorkEventArgs eWrk ) { worker.DoWork -= workHandler; ServiceProxy service = new ServiceProxy(); service.EventWorkCompleted += actionCompleted = delegate(<parameters>) { service.MethodWorkCompleted -= actionCompleted; currentDispatcher.BeginInvoke( new Action<<parameters>>( OnActionCompleted ), <parameters>); }; Messenger.Default.Send( new ShowProgressViewMessage( new ProgressViewModel( "Loading..." ) ) ); service.ServiceMethod(); }; worker.RunWorkerCompleted += doneHandler = delegate ( object oDone, RunWorkerCompletedEventArgs eDone ) { Logger.LogVerbose( "Method Called" ); worker.RunWorkerCompleted -= doneHandler; }; worker.RunWorkerAsync(); private void OnActionCompleted(<parameters>) { }

更新:只要改变因为版权问题的实施,希望你不要介意。

Update: Just change the implementation because of copyright issues, hope you don't mind.

更多推荐

项目组合框装事件WPF?

本文发布于:2023-11-05 15:30:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561217.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:组合   事件   项目   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!