private void AppendPinTiles()
        {
            HomePagePinTiles h = HomePagePinTiles.GetInstance();

            //var pinTileList = h.GetHomePagePinTileList();
            var pinTileList = MiscHelpers.GetItemFromIsolatedStorage<List<PinTile>>("fbd-pintiles.xml");

            if (pinTileList == null) return;

            int i = 0;
            UIElementCollection u = ContentPanel.Children;

            for (int j = 1; j < u.Count; j++)
            {
                var b = u[j] as RadCycleHubTile;
                if (b != null && i < pinTileList.Count)
                {
                    PinTile p = pinTileList[i];

                    b.Tag = p.StorageName;

                    b.Background = new SolidColorBrush(Colors.Gray);
                    b.Visibility = Visibility.Visible;

                    if (PinType.Category.Equals(p.PinTypeLabel))
                    {
                        var newsItem = new DataModel.UIContextItem
                        {
                            Visibility2 = Visibility.Collapsed
                        };
                        var newsItems = new List<DataModel.UIContextItem> { newsItem };
                        b.ItemsSource = newsItems;

                        if (p.TileImage != null)
                        {
                            b.Background = new ImageBrush()
                            {
                                ImageSource = new BitmapImage(new Uri(p.TileImage, UriKind.RelativeOrAbsolute)),
                                Stretch = Stretch.Fill
                            };
                        }
                    }
                    else if (PinType.SubCategory.Equals(p.PinTypeLabel) ||
                        "favourite".Equals(p.TileCategory) ||
                        "savelater".Equals(p.TileCategory) ||
                        "historicalview".Equals(p.TileCategory) ||
                        "fbfeeds".Equals(p.TileCategory))
                    {
                        var newsItem = new DataModel.UIContextItem
                        {
                            Opacity2 = 0.6,
                            Color2 = new SolidColorBrush(Colors.Black),
                            Text2 = p.Title,
                            Visibility2 = Visibility.Collapsed
                        };
                        var newsItems = new List<DataModel.UIContextItem> { newsItem };
                        b.ItemsSource = newsItems;

                        if (p.TileImage != null)
                        {
                            b.Background = new ImageBrush()
                            {
                                ImageSource = new BitmapImage(new Uri(p.TileImage, UriKind.RelativeOrAbsolute)),
                                Stretch = Stretch.UniformToFill
                            };
                        }
                    }
                    else if (p.StorageName != null && PinType.Channel.Equals(p.PinTypeLabel))
                    {
                        string encodedStorageName = HttpUtility.UrlEncode(p.StorageName);
                        DataModel.ChannelItem channelItem =
                            MiscHelpers.GetChannelItemFromIsolatedStorage(encodedStorageName + ".xml");
                        if (channelItem != null && channelItem.NewsItems != null && channelItem.NewsItems.Count > 0)
                        {
                            var newsItems = new List<DataModel.UIContextItem>();
                            foreach (var item in channelItem.NewsItems)
                            {
                                var uItem = MiscHelpers.CreateUINewsItem(item);
                                if (item.NewsImages != null && item.NewsImages.Count > 0 &&
                                    item.NewsImages[0] != null)
                                {
                                    var imageB = new BitmapImage(new Uri(item.NewsImages[0], UriKind.Absolute))
                                        {
                                            CreateOptions = BitmapCreateOptions.BackgroundCreation
                                        };
                                    imageB.ImageOpened += delegate
                                        {
                                            var u2 = uItem;

                                            var uItem2 = MiscHelpers.CreateUINewsItem(u2);
                                            uItem2.NewsImageSource = imageB;

                                            newsItems.Remove(u2);

                                            uItem2.Opacity2 = 0.6;
                                            uItem2.Color2 = new SolidColorBrush(Colors.Black);
                                            uItem2.Text2 = p.Title;

                                            uItem2.Visibility2 = Visibility.Visible;
                                            uItem2.Text1 = p.NumOfNewNewsItem.ToString();

                                            newsItems.Add(uItem2);
                                        };
                                }

                                if (p.TileImage != null)
                                {
                                    var image = new BitmapImage(new Uri(p.TileImage, UriKind.RelativeOrAbsolute));
                                    uItem.NewsImageSource = image;
                                }

                                uItem.Opacity2 = 0.6;
                                uItem.Color2 = new SolidColorBrush(Colors.Black);
                                uItem.Text2 = p.Title;
                                uItem.Text1 = channelItem.NumOfNewNewsItems.ToString();

                                uItem.Visibility2 = Visibility.Visible;

                                newsItems.Add(uItem);
                            }
                            b.ItemsSource = newsItems;
                        }
                    }

                    b.Tap += delegate
                        {
                            if ("fbfeeds".Equals(p.TileCategory))
                            {
                                Analytics.GetInstance().TrackHomeButtonPressed("tile_facebook");
                                Dispatcher.BeginInvoke(() => NavigationService.Navigate(new Uri("/FacebookLoginPage.xaml?type=tofeeds", UriKind.Relative)));
                            }
                            else if ("explore".Equals(p.TileCategory))
                            {
                                Analytics.GetInstance().TrackHomeButtonPressed("tile_explore");
                                Dispatcher.BeginInvoke(GoExploreList);
                            }
                            else if (PinType.Category.Equals(p.PinTypeLabel))
                            {
                                Analytics.GetInstance().TrackHomeButtonPressed("tile_category");

                                ToCategoryPage(p.TileCategory);
                            }
                            else if (PinType.SubCategory.Equals(p.PinTypeLabel) || PinType.Channel.Equals(p.PinTypeLabel))
                            {
                                Analytics.GetInstance()
                                         .TrackHomeButtonPressed(PinType.SubCategory.Equals(p.PinTypeLabel)
                                                                     ? "tile_subcategory"
                                                                     : "tile_channel");
                                Dispatcher.BeginInvoke(
                                    () =>
                                    NavigationService.Navigate(
                                        new Uri(
                                            "/NewsListPage.xaml?storage=" + p.StorageName + "&viewtype=" +
                                            p.PinTypeLabel + "&category=" + p.TileCategory,
                                            UriKind.Relative)));

                            }
                            else if (PinType.NewsItem.Equals(p.PinTypeLabel))
                            {
                                Dispatcher.BeginInvoke(
                                    () =>
                                    NavigationService.Navigate(new Uri("/NewsItemPage.xaml?storage=" + p.StorageName + "&itemguid=" + p.TileGuid + "&viewtype=" + p.PinTypeLabel,
                                                                       UriKind.Relative)));
                            }
                        };

                    i++;
                }
            }
        }
 public static DataModel.UIContextItem CreatePage2ToUIContextItem(Page2 p)
 {
     var uItem = new DataModel.UIContextItem()
     {
         Tag = p.Tag1,
         FeedTitle = p.FeedTitle1,
         FeedUrl = p.FeedUrl1,
         //FeedLink = p.FeedLink1,
         //FeedAuthor = p.FeedAuthor1,
         //FeedDescription = p.FeedDescription1,
         NewsTitle = p.NewsTitle1,
         //NewsLink = p.NewsLink1,
         //NewsAuthor = p.NewsAuthor1,
         NewsSnippet = p.NewsSnippet1,
         //NewsContent = p.NewsContent1,
         NewsImages = p.NewsImages1,
         NewsPublishedDateDisplay = p.NewsPublishedDateDisplay1,
         //NewsPublishedDateTimeStamp = p.NewsPublishedDateTimeStamp1,
         NewsImageSource = p.NewsImageSource1,
         ImageFavourite = p.ImageFavourite1,
         ImageReadLater = p.ImageReadLater1
     };
     return uItem;
 }