开发者

Favorites in a Windows Phone Panorama application

I have a Panorama Application, where one of the panorama items is 'Favorites'. I used a standard Windows Phone project with ItemViewModel and MainViewModel to get started. I replaced the lineone/two/three with a simple string 'Favorite'. I actually load the favorites data from isolated storage in the LoadData() function, and populate 'Items' using:

        IsolatedStorageFileStream favoritesFile = store.OpenFile("favorites.txt", FileMode.OpenOrCreate, FileAccess.Read); 
        string lines; 

        Items.Clear(); 
        using (StreamReader reader = new StreamReader(favoritesFile)) 
        { 
            while ((lines = reader.ReadLine()) != null) 
            { 
                this.Items.Add(new ItemViewModel() { Favorite = lines }); 
            } 
        } 

I'd like to be able to not just view my favorites in this panorama item, but delete them as well (adding an item as favorite is covered when I navigate to the item detail page). Two options I've considered are:

  • Displaying a yellow star next to the text. Clicking on the star would remove the item from the list.
  • Some sort of press and hold --> delete action.

For the first one, I'm not sure how to refresh the list once the item is d开发者_如何学运维eleted. Apparently, I cannot navigate to the same page :) Also, how can I tell which star corresponds to which favorite item, since the favorite item will be bound in xaml, like so:

                            <TextBlock Margin="10,10,0,0" Text="{Binding Favorite}" TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" Grid.Column="0" />
                            <Button Grid.Column="1" Click="FavoriteButton_Click" BorderThickness="0" Height="40">
                                <Button.Background>
                                    <ImageBrush ImageSource="/WindowsPhonePanoramaApplication2;component/Images/appbar.feature.email.rest.png" Stretch="None" />
                                </Button.Background>
                            </Button>

For the second one, discoverability is an issue, plus I don't even know if this is supported for third party apps. I'm leaning towards the first option as it's fairly intuitive. Please advise.


If your todo list is an ObservableCollection that sends out NotifyPropertyChanged event when it is changed, then you don't need to worry about reloading the list your self, databinding takes care of this itself.

For the discoverability, press and hold is quite common i think. The press and hold component (context menu) is available for free in Silverlight Toolkit for WP7 (http://silverlight.codeplex.com)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜