Not able to update ui layer in selectionchanged event

4 posts, 0 answers
  1. FieldTRAKS
    FieldTRAKS avatar
    25 posts
    Member since:
    Apr 2009

    Posted 17 Sep 2009 Link to this post

    I have a multi tabbed tabcontrol where each tab control has a gridview. The first time a user clicks a tab I bind the data to the gridview. There is a long pause when a user first clicks on the tab and I can live with that. However, I can't seem to get my status bar to display or even just change the Tabitem header to read "Loading" while the tabitem is rendered. I am subscribing to the selectionchanged event  but my first few lines of code seem not to run until the entire procedure completes.
     My code is as follows (BTW I have tried using background workers to do the heavy lifting to no avail.) I put some comments in the code lines to indicate where I am having the problem.

            void tc_SelectionChanged(object sender, RoutedEventArgs e)
            {
                Telerik.Windows.Controls.RadTabControl tc = (Telerik.Windows.Controls.RadTabControl)sender;

              //this is a tabitem class derived from RadTabItem
                FTSilverControls.FTReportTabItem ti = (FTSilverControls.FTReportTabItem)tc.Items[tc.SelectedIndex];

                
                if (f.CanShowHistory)
                {
                    try
                    {
                     
                         List<string> ids = new List<string>();
                ids.Add(rad.Data[0].DataItems[0].Uid);
                if (!ti.IsPopulated)
                {
                    tc.FontSize = 20;
    //the ui layer does not seem to process until ProcessActivityTab completes which essentially means you never see my status bar.
    //I have tried invalidating the control, calling update layout, pausing the thread

                    ShowStatus("Formatting Data for " + ti.Header.ToString());

                    ProcessActivityTab(ti);

                }
                       
                        
                    }

                    catch
                    {
                    }

                }

                else
                {
                    tabs.Add(ti);
                }
               
            }


            private void ProcessActivityTab(FTSilverControls.FTReportTabItem ti)
            {
                FTSilverControls.FTGenericReportTable win = new FTSilverControls.FTGenericReportTable(ti.Header.ToString(), a.ReadFromStorage(ti.Tag.ToString(), a.SpecialDirs["dialogs"], true), a.HistoryDocuments[ti.Tag.ToString()], a.Username, a.Password, ids, "", a.Menunames, false);

                FTSilverControls.FTGenericReport rep = new FTSilverControls.FTGenericReport(win);
                ti.AddReport(rep);
                rep.Height = 310;
                rep.Width = 1145;
                ti.Gv = win.Gview;

                ti.Rep.DoAutoFilter(GetSelectionLayerNames(rad.SelectionManager.SelectedItems[0], "id"));
                HideStatus();
            }
  2. FieldTRAKS
    FieldTRAKS avatar
    25 posts
    Member since:
    Apr 2009

    Posted 18 Sep 2009 Link to this post

    Is anybody watching this post???
  3. DevCraft banner
  4. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 22 Sep 2009 Link to this post

    Hi Dave Branson,

    I am sorry for the delayed reply,

    It seems that the UI thread is busy while the processing works. Have you tried putting the blocking activity in a Dispatcher? This way hopefully the UI will have time to update:

    ShowStatus("Formatting Data for " + ti.Header.ToString());
    statusViewControl.UpdateLayout()
    this.Dispatcher.BeginInvoke( () => ProcessActivityTab(ti) );

    Does this work in your case?

    Greetings,
    Miroslav
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. FieldTRAKS
    FieldTRAKS avatar
    25 posts
    Member since:
    Apr 2009

    Posted 22 Sep 2009 Link to this post

    Yes...that works perfectly...thanks for the new trick miroslav!
Back to Top