This is a migrated thread and some comments may be shown as answers.

Not able to update ui layer in selectionchanged event

3 Answers 63 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
FieldTRAKS
Top achievements
Rank 1
FieldTRAKS asked on 17 Sep 2009, 01:15 PM
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();
        }

3 Answers, 1 is accepted

Sort by
0
FieldTRAKS
Top achievements
Rank 1
answered on 18 Sep 2009, 04:47 PM
Is anybody watching this post???
0
Miroslav
Telerik team
answered on 22 Sep 2009, 08:20 AM
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.
0
FieldTRAKS
Top achievements
Rank 1
answered on 22 Sep 2009, 12:50 PM
Yes...that works perfectly...thanks for the new trick miroslav!
Tags
TabControl
Asked by
FieldTRAKS
Top achievements
Rank 1
Answers by
FieldTRAKS
Top achievements
Rank 1
Miroslav
Telerik team
Share this question
or