0

I am developing an app on win8 and would like to add an 'AddToFavorites' button on the application bar, so that the user can select his favorites/bookmarks and place them to this. I have added this button to the application bar but the button does not perform any action when clicked.

Currently what I have done is

    private async void Favorite_Button_Click(object sender, RoutedEventArgs e)
    {

         if (SampleDataSource.GetGroup("Favorite").Items.Count != 0)
        {
            if (this.pageTitle.Text != "Favorite")
                this.Frame.Navigate(typeof(ItemDetailPage),                         SampleDataSource.GetGroup("Favorite").Items[0].UniqueId);
        }
        else
        {
            await new Windows.UI.Popups.MessageDialog("You haven't marked any favorites.").ShowAsync();

        }
    }

But I dont see this functionality working. Any of your suggestions would be of great help to me. It is a Windows8 Metro style C#/XAML App. Thanks in Advance!

dmurali
  • 211
  • 1
  • 6
  • 14
  • You need to clarify your question. As it is written we have no idea what you mean by "getting it working". – chue x Oct 09 '13 at 00:37
  • I meant that, when the user clicks on the favorites button, nothing happens, there is no action taking place. – dmurali Oct 09 '13 at 07:51
  • On the itemviewpage, the user should be able to click a page as his fav/unfav at any time. is it possible? – dmurali Oct 09 '13 at 09:49
  • 1
    I assume you are sure that this handler gets called and the 'Navigate' method gets called but nothing happens. right? Have you tried using RunAsync? Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => this.Frame.Navigate(typeof... – n00b Oct 09 '13 at 21:37
  • True that 'navigate' method gets called but nothing happens. Now, I tried giving only `if (itemListView.SelectedItems.Count == 1) { Favorite.Visibility = Visibility.Collapsed; } else { Favorite.Visibility = Visibility.Visible; } ` In this case, when an item is clicked, favorite button gets collapsed but does not re-appear when another item in the same page gets clicked again. – dmurali Oct 10 '13 at 08:56
  • And also `await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { this.Frame.Navigate(typeof(GroupedItemsPage), SampleDataSource.GetGroup("Favorite").Items[0].UniqueId); }); var ignored = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { });` dint make any difference – dmurali Oct 10 '13 at 08:59
  • Edited the code a litle bit to see if it works, but no use! `var y = this.itemListView.SelectedItems; if (this.itemListView.Visibility == Windows.UI.Xaml.Visibility.Collapsed) { y = this.itemListView.SelectedItems; } foreach (var x in y) { SampleDataItem i = x as SampleDataItem; var f = SampleDataSource.GetGroup(""); if (!SampleDataSource.FavoriteManager.isFavorite(int.Parse(i.UniqueId))) await SampleDataSource.addToGroupByNum(int.Parse(i.UniqueId), f); SampleDataSource.FavoriteManager.WriteFavs(); }` – dmurali Oct 11 '13 at 10:50

0 Answers0