0
我對「Windows Phone模擬器 - WVGA 512 MB」和我的設備有以下例外。在使用「Windows Phone Emulator - WVGA」時,我不會遇到這個問題。OutOfMemoryException未處理
這是我的XAML
<phone:Panorama Name="pano" >
</phone:Panorama>
這是我的代碼背後
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);
}
你爲什麼要這樣做'try' /'catch'塊?這是一個可怕的做法。當你刪除它會發生什麼? – Enigmativity 2014-08-28 07:13:00
thw同樣的問題,我這樣做,試圖解決這個問題 – 2014-08-28 07:25:13