0

データがランダムに変化するリストを介してデータがバインドされる動的ピボットを作成しました。ほとんどの範囲はリスト内の 100 ~ 150 エントリです。すべてがうまくいき、データがリストに追加されますが、データがバインドされるとアプリが予期せず終了し、メモリ不足の例外が表示されます

私のコードは何とかこのxamlのようです

<Controls:Pivot x:Name="pvtDeals" Background="Gray" ItemsSource="{Binding CityItemList}" Grid.Row="1">
   <Controls:Pivot.ItemTemplate>
       <DataTemplate>
           <Grid >
               <Grid.RowDefinitions>
                   <RowDefinition Height="200"/>
                   <RowDefinition Height="Auto"/>
                   <RowDefinition Height="*"/>
               </Grid.RowDefinitions>
               <Image x:Name="imgDeal" Tag="0" Source="{Binding ImageLink}" Stretch="Uniform" HorizontalAlignment="Stretch"  />
               <TextBlock Foreground="Red" Text="{Binding Title}" Grid.Row="1" TextWrapping="Wrap"/>
               <ScrollViewer Grid.Row="2">
                   <TextBlock Foreground="Black" Text="{Binding Description}" TextWrapping="Wrap" Grid.Row="2"/>
               </ScrollViewer>
           </Grid>
       </DataTemplate>
   </Controls:Pivot.ItemTemplate>
</Controls:Pivot>

csコード

var xml = XDocument.Parse(e.Result); // from XML string, e.g.


// SaveDealInfoToIsolatedStorage(e.Result);

System.Text.RegularExpressions.Regex rx = new System.Text.RegularExpressions.Regex("<[^>]*>");

        var Channel = xml.Root.Elements("channel").ToList();
        var items = Channel[0].Elements("item").ToList();
        App.MainViewModel.CityItemList.Clear();

        foreach (var item in items)
        {
            App.MainViewModel.CityItemList.Add(new Model.CityItems
                {
                    Title = item.Element("title").Value,
                    Description = rx.Replace(item.Element("description").Value.Replace("\"", string.Empty), string.Empty),
                    ImageLink = item.Element("imageURL").Value,//image,
                    WebLink = item.Element("link").Value
                });

            System.Diagnostics.Debug.WriteLine(App.MainViewModel.CityItemList.Count.ToString());
        }
4

0 に答える 0