首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Telerik BusyIndicator不显示

Telerik BusyIndicator不显示
EN

Stack Overflow用户
提问于 2013-03-19 18:39:23
回答 5查看 3.3K关注 0票数 1

我正在使用WCF服务

我有这个问题:

当我在异步函数调用开始时从服务器为我的GridView检索数据时,我设置了IsBusy = "True"。在调用该方法之后,我设置了IsBusy = "False"。在方法调用期间,不显示RadBusyIndicator。我不明白问题出在哪里。

我已经上传了一个简单的项目与这个问题。你能检查一下吗?Download

EN

回答 5

Stack Overflow用户

发布于 2013-03-19 19:28:46

我在BackgroundWorker中移动了加载,你能试试这个吗:

代码语言:javascript
复制
private void LoadData()
{
    //Activate BudyIndicator
    App.Instance.SetBusy();

    BackgroundWorker worker = new BackgroundWorker();
    worker.DoWork += (o, ea) =>
    {
        ObservableCollection<CustomerModel> LoadedCustomers = null;

        //Create Client
        proxy.ServicesClient client = new proxy.ServicesClient();
        ObservableCollection<Customer> customers = client.GetCustomers();

        LoadedCustomers = new ObservableCollection<CustomerModel>();
        foreach (var item in customers)
        {
            LoadedCustomers.Add(new CustomerModel()
            {
                CustomerId = item.CustomerId,
                Title = item.Title,
                FirstName = item.FirstName,
                MiddleName = item.MiddleName,
                LastName = item.LastName,
                CompanyName = item.CompanyName,
                SalesPerson = item.SalesPerson,
                EmailAddress = item.EmailAddress,
                Phone = item.Phone
            });
        }
        client.Close();

        //Define return value
        ea.Result = LoadedCustomers;
    };
    worker.RunWorkerCompleted += (o, ea) =>
    {
        //Get returned value
        ObservableCollection<CustomerModel> model = ea.Result as ObservableCollection<CustomerModel>;
        if (model != null)
        {
            Customers = model;
        }

        //Desactivate BusyIndicator
        App.Instance.UnSetBusy();
    };
    worker.RunWorkerAsync();
}
票数 0
EN

Stack Overflow用户

发布于 2013-03-20 00:32:50

好的,我明白你的问题了。代理上的Close方法等待异步调用的结果。只需在GetCustomersCompleted方法中移动您的client.Close();,这将会起作用。(使用您的样本进行测试)

代码语言:javascript
复制
private proxy.ServicesClient client = null;
private void LoadData()
{
    App.Instance.SetBusy();

    client = new proxy.ServicesClient();
    client.GetCustomersCompleted += (s, e) =>
    {
        if (e.Error != null)
        {
            throw new Exception();
        }
        else
        {
            Customers = new ObservableCollection<CustomerModel>();

            foreach (var item in e.Result)
            {
                Customers.Add(new CustomerModel()
                    {
                        CustomerId = item.CustomerId,
                        Title = item.Title,
                        FirstName = item.FirstName,
                        MiddleName = item.MiddleName,
                        LastName = item.LastName,
                        CompanyName = item.CompanyName,
                        SalesPerson = item.SalesPerson,
                        EmailAddress = item.EmailAddress,
                        Phone = item.Phone
                    });
            }

            OnPropertyChanged("Customers");
        }
        client.Close();//Close after the return
        App.Instance.UnSetBusy();
    };
    client.GetCustomersAsync();
    //client.Close();
}
}
票数 0
EN

Stack Overflow用户

发布于 2013-03-21 11:19:55

如果您的窗口xaml不在忙指示器内,它可能不会显示。使用该控件,当繁忙指示器设置为true时,您需要将希望屏蔽的内容放在指示器标记内。如果您的UserControl的主要显示项是一个网格,则将该网格包含在繁忙指示器标记中。

代码语言:javascript
复制
<UserControl>
  <telerik:RadBusyIndicator IsBusy={Binding Busy}>
      <Grid>
         content...
      </Grid>
   </telerik:RadBusyIndicator>
</UserControl>

这应该会给你想要的结果。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15497169

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档