Reputation: 71
I get the following exception for the "Windows Phone Emulator - WVGA 512 MB" and my device. I do not get this problem when using the "Windows Phone Emulator - WVGA".
this is my xaml
<phone:Panorama Name="pano" >
</phone:Panorama>
this is my code behind
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (e.NavigationMode != NavigationMode.Back)
{
type = NavigationContext.QueryString["type"];
ReadFromXml(type);
}
}
private void ReadFromXml(string type)
{
XDocument xml=XDocument.Load(@"data/image_saba7.xml");
var query = from c in xml.Root.Descendants("post")
select c.Element("image").Value;
foreach (var name in query)
{
createPanoramItem("", name);
}
}
private void createPanoramItem(string tit, string imgurl)
{
BitmapImage image = new BitmapImage(
new Uri(imgurl, UriKind.Relative)
);
Grid g = new Grid();
Image im = new Image
{
Source = image,
VerticalAlignment = System.Windows.VerticalAlignment.Center,
Margin = new Thickness(10, 290,-10, 80),
};
img = imgurl;
im.Tap += im_Tap;
TextBlock t = new TextBlock
{
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(10, 296, 10, 300),
HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
TextAlignment = TextAlignment.Right,
FontSize = 25,
FontWeight = System.Windows.FontWeights.SemiBold,
Foreground = new SolidColorBrush(new Color()
{
A = 255 /*Opacity*/,
R = 132 /*Red*/,
G = 91 /*Green*/,
B = 54 /*Blue*/
}),
Text = tit
};
g.Children.Add(t);
g.Children.Add(im);
PanoramaItem panoramaCtrlItem = new PanoramaItem();
panoramaCtrlItem.Content = g;
// panoramaCtrlItem.Header = title;
pano.Items.Add(panoramaCtrlItem);
}
Upvotes: 0
Views: 140
Reputation: 7215
You're using too much RAM. You'll need to figure out a way to get rid of a couple of items in your panorama, or develop a scheme by which you only load things as they become relevant, e.g. load an image only just before it is displayed on the screen.
So, instead of loading the images all at once, load them as the user swipes left or right. Or decide on a number per "page" and only load that much at a time.
Upvotes: 2