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

EnableAsyncBalance and BeginAsyncBalance method

3 Answers 54 Views
DataBoundListBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
keith patton
Top achievements
Rank 1
keith patton asked on 28 May 2011, 11:16 AM
I am using the MVVM pattern and found this blog post:
http://blogs.telerik.com/blogs/posts/11-05-12/windows_phone_7_mvvm_1_raddataboundlistbox.aspx

However, when I look at your examples there is in the ListExampleBase.cs a method call BeginAsyncBalance in addition to the ItemsSource property being set manually in code (as opposed to a Binding element in xaml in the View which is what I currently have as per the blog post.

  protected virtual void DisplayData(IEnumerable items)
        {
........

            this.Dispatcher.BeginInvoke(() =>
            {
                this.ListBox.BeginAsyncBalance();
                this.ListBox.ItemsSource = items;
            });
        }


In addition, when the list box has been loaded (in the OnLoaded method of same class), the following property is set. Again, is this important, and what exactly does this do?

          this.ListBox.IsAsyncBalanceEnabled = this.EnableAsyncBalance;

If you could please explain whether it is best practice to set this property and call this method at these particular points in the control's lifecycle? If so, why do they need to be controlled manually?

I'm really after a 'sensible default' here. My listbox will have 'More' enabled to allow paging, but is unlikely to get bigger than 1-200 items. The templating will however be very rich if this helps. 

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 31 May 2011, 03:40 PM
Hi Keith,

Thanks for writing and for your questions.

You can find more information about the asynchronous balance feature here:

http://www.telerik.com/help/windows-phone/raddataboundlistbox-features-asynchronous-balance.html

In general, this feature instructs the control to offload the UI thread upon the realization of a single RadDataBoundListBoxItem (the visual container for a single data item) thus leaving space for rendering and manipulation events processing. Since sometimes the user may define more complex Item Templates thus making the initial loading time consuming, the async balance allows for improving the user experience by not loading all containers at once but at very small time intervals thus leaving the UI thread to process rendering and user input as well.

I hope this answers your questions.

Do not hesitate to get back to us in case you have further questions or need assistance.

Best wishes,
Deyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
keith patton
Top achievements
Rank 1
answered on 02 Jun 2011, 01:52 PM
Thanks. So how can we apply an MVVM binding from a view model property? Do we have to manually apply these properties in code and set ItemsSoruce to get the desired effect, or can i get the benefits of this approach on my listbox declaratively in xaml, i couldn't see how?

I'm trying to reduce or eliminate any extra code if i wanted this behaviour as the default.
0
Accepted
Deyan
Telerik team
answered on 02 Jun 2011, 02:16 PM
Hi Keith,

You can completely configure the RadDataBoundListBox in XAML and still use the Async Balance functionality. The ScheduleAsyncBalance method allows you to simply explicitly say that you want the next UI virtualization algorithm pass to be async. In general, you only need to have the IsAsyncBalanceEnabled set to true and the control will internally call ScheduleAsyncBalance when needed so you do not have to bother about it.

I am attaching a demo project which demonstrates how you can use MVVM and RadDataBoundLIstBox without coding.

I hope it helps.

You can write back anytime you need further assistance.

All the best,
Deyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
DataBoundListBox
Asked by
keith patton
Top achievements
Rank 1
Answers by
Deyan
Telerik team
keith patton
Top achievements
Rank 1
Share this question
or