0

我有一个全景应用程序,其中一个全景项目是“收藏夹”。我使用了一个带有 ItemViewModel 和 MainViewModel 的标准 Windows Phone 项目来开始。我用一个简单的字符串“Favorite”替换了 lineone/two/three。我实际上从 LoadData() 函数中的隔离存储中加载收藏夹数据,并使用以下方法填充“项目”:

        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 }); 
            } 
        } 

我希望不仅能够在此全景项目中查看我的收藏夹,而且还可以删除它们(当我导航到项目详细信息页面时,会将项目添加为收藏夹)。我考虑过的两个选项是:

  • 在文本旁边显示一个黄色星号。单击星号将从列表中删除该项目。
  • 某种按住->删除操作。

对于第一个,我不确定删除项目后如何刷新列表。显然,我无法导航到同一页面 :) 另外,我如何判断哪个星对应于哪个收藏项,因为收藏项将绑定在 xaml 中,如下所示:

                            <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>

对于第二个,可发现性是一个问题,而且我什至不知道第三方应用程序是否支持这一点。我倾向于第一个选项,因为它相当直观。请指教。

4

1 回答 1

1

如果您的待办事项列表是一个 ObservableCollection,它在更改时发出 NotifyPropertyChanged 事件,那么您不必担心自己重新加载列表,数据绑定会自行处理。

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)

于 2011-06-06T09:41:35.613 回答