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

Silverlight 5 broke RadTreeView

4 Answers 35 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
stephen
Top achievements
Rank 1
stephen asked on 10 Sep 2013, 08:00 AM
Hi there,

My company released a product with Silverlight 4 which made use of the RadTreeView. It read a list of items to put into the tree from our server and then as you scrolled down the treeview, more items would populate. Since a MS update to install Silverlight 5, we found that although the scrollbar is still the correct size (ie small), when scrolling down, we only see the first 20 items in the treeview, with nothing below. Uninstalling silverlight 5 and reInstalling Silverlight 4 fixes the issue. Do you know what in Silverlight 5 could cause the tree to not draw items when you scroll down? Is there a new dll or version of the radtreeview that we should use instead, made to work with Silverlight 5?

thanks,
Stephen 

4 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 12 Sep 2013, 10:09 AM
Hello Stephen,

You need to keep in mind that since Q1 2013 we do not support Silverlight4 and we no longer ship dlls for that version of the platform. Hence, we strongly recommend to our customers to use our latest official releases and Silverlight5.

As your project fails to run on SL5 we would like to take a look at your current implementation. If you isolate the reported issue in a separate project and send it over we will be able to investigate the reasons behind the reported behavior.

Thank you in advance for your kind cooperation.

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
stephen
Top achievements
Rank 1
answered on 16 Sep 2013, 06:16 AM
Thanks for your reply.

We found that after upgrading to your Silverlight 5 controls and building our project with Target Silverlight Version = Silverlight 5, nothing at all showed in the radtreeview. 

Some investigation led us to this code:

var assets = new List<AssetViewModel>
                                     {
                                         new AssetViewModel
                                             {
                                                 PointName = createAssetCursorCompletedEventArgs.RootAsset.PointName,
                                                 ItemName = createAssetCursorCompletedEventArgs.RootAsset.ItemName,
                                                 HasChildren = createAssetCursorCompletedEventArgs.RootAsset.HasChildren,
                                                 IsAssigned = createAssetCursorCompletedEventArgs.RootAsset.Assigned,
                                                 IsRoot = true
                                             }
                                     };

Assets.ItemsLoading += (t, args) => AssetsItemsLoading(assets[0], args);
Assets.VirtualItemCount = 1;

We have been setting the VirtualItemCount to 1 and populating it with a dummy entry, and then when Telerik's ItemsLoading event is fired, we go off to our server and ask how many elements are in the tree. After this happens we set VirtualItemCount to this new value and populate the tree. 

After upgrading to Silverlight 5, we found that the Telerik ItemsLoading event is not fired, unless we set Assets.VirtualItemCount to a number > 1 initially in the code above (eg 2). This fixes the issue, however, we found that if we set that default value to a number greater than the total number of elements that our server tells us to put in the tree, the entire tree disappears and crashes our Silverlight control. This means we cannot have a tree with exactly 1 element, so is not an acceptable solution. Could you please tell us what has changed with Itemsloading and VirtualItemCount between silverlight 4 and 5 versions of the controls?
0
Rhett
Top achievements
Rank 1
answered on 17 Sep 2013, 05:08 AM
Some further information

When we first load our UI, we put a dummy VirtualQueryableCollectionView into our treeview that is intiialised like this:

public VirtualQueryableCollectionView Assets
        {
            get
            {
                if (_assets == null)
                {
                    if (HasChildren)
                    {
                        // we initialize with a dummy collection until required to provide the real collection
                        _assets = new DummyVirtualQueryableCollectionView
                                      {
                                          LoadSize = 1,
                                          VirtualItemCount = 1
                                      };
                    }
                    else
                    {
                        _assets = new VirtualQueryableCollectionView
                        {
                            LoadSize = 0,
                            VirtualItemCount = 0
                        };
                    }
                }
 
                return _assets;
            }



 In our initialise method, comes the code mentioned earlier where we set VirtualItemCount to 1 for this dummy entry:


var assets = new List<AssetViewModel>
                                     {
                                         new AssetViewModel
                                             {
                                                 PointName = createAssetCursorCompletedEventArgs.RootAsset.PointName,
                                                 ItemName = createAssetCursorCompletedEventArgs.RootAsset.ItemName,
                                                 HasChildren = createAssetCursorCompletedEventArgs.RootAsset.HasChildren,
                                                 IsAssigned = createAssetCursorCompletedEventArgs.RootAsset.Assigned,
                                                 IsRoot = true
                                             }
                                     };
                     
                           Assets.VirtualItemCount = 1;
                           Assets.ItemsLoading += (t, args) => AssetsItemsLoading(assets[0], args);
                            
 
                           // following line will kick off population of the asset tree,
                           // which in turn will kick off population of the activities grid
                           Assets.Load(0, assets);


In the event handler for AssetsItemsLoading, we call our server to find the real number of elements in the tree, and when that comes back we do this to replace the dummy viewmodel:


void OnGetChildAssetCountCompleted(object sender, GetChildAssetsCountCompletedEventArgs e)
        {
            if (e.Result.ErrorCode != 0)
            {
                _logger.Error("GetChildAssetCount failed with error " + e.Result.ErrorCode + ":" + e.Result.ErrorMessage);
                Close();
                return;
            }
            var userState = e.UserState as ItemsLoadingUserState;
            if (userState != null)
            {
                AssetViewModel assetViewModel = userState.ViewModel;
                if (assetViewModel.Assets is DummyVirtualQueryableCollectionView)
                {
                    // replace the dummy collection with the real one
                    assetViewModel.Assets = new VirtualQueryableCollectionView
                    {
                        LoadSize = 20,
                        VirtualItemCount = (int)e.ChildCount
                    };
                    assetViewModel.Assets.ItemsLoading += (s, args) => AssetsItemsLoading(assetViewModel, args);
                }
                else
                {
                    _activityClient.GetChildAssetsInViewAsync(_assetCursorIndex, userState.ViewModel.PointName, (uint)userState.StartIndex, (uint)userState.ItemCount, userState);
                }
            }
        }


When Assets.VirtualItemCount = 1; in the second piece of code, the ItemsLoading event never gets fired in
Silverlight 5, and therefore the real viewmodel is never substituted in for the dummy in the 3rd piece of
code.

If I change Assets.VirtualItemCount = 2; In the 2nd piece of code, then my tree fills up correctly, but 
there is one blank entry at the bottom, presumably for the original dummy value that was supposed to 
be substituted out in the 3rd piece of code. The reason I think this is that if I change the
original VirtualItemCount to 5, there are 5 blank rows at the bottom of my tree. It like setting
assetViewModel.Assets = new VirtualQueryableCollectionView... is not actually replacing my
VirtualQueryCollectionView, but rather, putting the real data before it at the top of the tree.
Furthermore, if I set the VirtualItemCount to a number greater than how many values are going to come 
from the server, the entire control crashes after receiving the data. This is avoided by setting 
LoadSize = 100 or any number greater than or equal to the number of real entries in the tree coming
back from the server.

hope this helps.
0
Pavel R. Pavlov
Telerik team
answered on 18 Sep 2013, 07:25 AM
Hello Rhett,

You are right about the blank rows. Items are created in order to match the VirtualItemsCount and if not populated they stay blank.
Thank you for the additional information you sent. Based on it I have managed to create a sample project where TreeView is bound to a VirtualQueriableCollectionView. I have used the setup VirtualItemsCount=1 and LoadSize=100. In this scenario the ItemsLoading event is fired initially. As you could see I am modifying the VirtualItemsCount later on in the event.
Also, I have noticed you are inserting one item in the collection initially. 

I could not managed to crash the application or miss the initial firing of the event. Could you please take a look at the sample project and check whether it fits to your case? If not, could you please modify the sample in order to introduce the issue?

Regards,
Pavel R. Pavlov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TreeView
Asked by
stephen
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
stephen
Top achievements
Rank 1
Rhett
Top achievements
Rank 1
Share this question
or