vodkhang
vodkhang

Reputation: 18741

How to know when all controls and templates are loaded (Windows Phone 7)

I am trying to lazy load the Image Source for the Image Control but the problem is that I have to wait for all controls loaded so that I can use VisualTreeHelper to access to the Image control (which inside a datatemplate).

I tried with Loaded event, LayoutUpdated even, ApplyTemplate like in the manual of msdn but for all of them, when I tried to get the container for Image Control, it is null

    var containerItem = FeedsPanorama.ItemContainerGenerator.ContainerFromIndex(selectedIndex);

    var imageControl = VisualElementHelper.FindName<Image>("ImageThumbnail", containerItem);

    new ImageUtility().GetImageAsyn(new Uri(selectedItem.SummaryImageLink, UriKind.Absolute), imageControl);

The same code will work when I handle in Selection_Changed event of FeedsPanaroma

Upvotes: 0

Views: 706

Answers (2)

vodkhang
vodkhang

Reputation: 18741

I tried to work around so that I don't have to deal with the Loaded Event. I wrote a new ImageConverter so that I can use that tag to replace the Image tag. It works like a charm

Upvotes: 0

Mick N
Mick N

Reputation: 14882

Have you tried the Loaded event for the page?

Upvotes: 1

Related Questions