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

Unsubscribing from VirtualDataCollection.ItemsLoading

3 Answers 27 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.
Vitalii
Top achievements
Rank 2
Vitalii asked on 21 Aug 2013, 08:56 AM
I just noticed, that something is wrong with unsubscribing.

Trying to divide large problem into smaller pieces.

Lets start from the very beginning.
I have a page with products categories A, and page with products list B (which obviously depends on category).
In my case, while navigating from A to B, i'm sending parameter in navigation string.
That means, i cant allow VirtualDataCollection to raise ItemsLoading event before OnNavigatedTo();

So, i'm unsubscribing it in OnNavigatedFrom()

public void OnNavigatedFrom()
        { 
            VirtualDataCollection.ItemsLoading -= VirtualDataCollectionOnItemsLoading;
            VirtualDataCollection.Clear();
 
            Cleanup();
        }
Aaand subscribe in OnNavigatedTo()
public void OnNavigatedTo()
        {
            VirtualDataCollection.ItemsLoading += VirtualDataCollectionOnItemsLoading;
        }

However, something is going on wrong: when i'm visiting page second time, ItemsLoading is called several times with the same parameters.
Can you check that?

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 21 Aug 2013, 02:48 PM
Hello Vitalii,

Thanks for writing.

Since I do not have many details about the scenario, my first step would be to check if the ItemsLoading event has already been handled before subscribing for it again. Or simply unsubscribe from it each time you subscribe for it.

If this resolves the problem what have caused it would be multiple subscription for it by providing the same handler.

Regards,
Deyan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
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
Vitalii
Top achievements
Rank 2
answered on 21 Aug 2013, 02:55 PM
Well, this is a bit isolated case, so we can discuss it without sample project.
The thing is that I'm subscribing only once, when navigatingTo page, and unsybscribe also once, when navigatingFrom page.
However, when I'm visiting page for a second time, event isrising twice. Second time, callstack is quite strange, looking like it is called from other thread.
0
Deyan
Telerik team
answered on 21 Aug 2013, 03:04 PM
Hi Vitalii,

Thanks for writing back.

It seems what happens is somehow related to your particular scenario.
Please make sure to include the scenario in the sample project we have agreed upon and we will review it.

Regards,
Deyan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINDOWS PHONE 7.
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
DataBoundListBox
Asked by
Vitalii
Top achievements
Rank 2
Answers by
Deyan
Telerik team
Vitalii
Top achievements
Rank 2
Share this question
or