项目组合框装事件WPF? [英] ComboBox items loaded event wpf?

查看:94
本文介绍了项目组合框装事件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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆