基本上,我差不多完成了这个笔记应用,用户保存笔记等基本笔记应用功能。我没有完全完成的原因是我只需要帮助我的应用程序添加瓷砖的笔记。基本上用户点击菜单项中的“Pin to start”和所选的音符,即开头的引脚。我通过以下方式完成了这项工作:
Private Sub PinToStart_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs)
Dim Storage As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Dim data As SampleData = TryCast(TryCast(sender, MenuItem).DataContext, SampleData)
Dim selectedItem As ListBoxItem = TryCast(Me.SavedNotesList.ItemContainerGenerator.ContainerFromItem(data), ListBoxItem)
Dim directory As String = "./MyNote/SavedNotes/*.*"
Dim filenames As String() = Storage.GetFileNames(directory)
Dim dataSource As New List(Of SampleData)()
For Each filename As String In filenames
Dim ISF As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
Dim FS As IsolatedStorageFileStream = ISF.OpenFile("MyNote/SavedNotes/" & filename, FileMode.Open, FileAccess.Read)
Dim FETime As String = Storage.GetCreationTime("MyNote/SavedNotes/" & data.FileNameX).ToString("dd/mm/yyyy h:mmtt")
Dim tileData As New StandardTileData() With { _
.Title = data.FileNameX, _
.BackgroundImage = New Uri("/Assets/202.png", UriKind.Relative), _
.BackTitle = data.FileNameX, _
.BackContent = data.Description}
ShellTile.Create(New Uri("/ViewPage.xaml?Title=" & data.FileNameX & "&Body=" & data.Description, UriKind.Relative), tileData)
Next
End Sub
目前,这是创建磁贴的代码。虽然存在一个问题,但是一旦创建了tile,它就会抛出一个异常并说“Tiles只能在应用程序位于前台时创建”但它仍然会继续并创建没有问题的tile。我遇到的第二个错误是我需要一种方法来更新磁贴。我只是不知道如何。
任何人都可以帮助我吗?
答案 0 :(得分:2)
使用Microsoft.Phone.Controls.Toolkit中的HubTile控件创建tile 你可以试试这段代码: var shellTileData = new StandardTileData { BackgroundImage = new Uri(“Path for image”,UriKind.RelativeOrAbsolute), BackContent =“xyz”
};
var tile = ShellTile.ActiveTiles.First();
tile.Update(shellTileData);