我只是想知道是否有合法的方式来创建和添加我的应用程序中的图块。由于我正在制作这个记录并保存它的应用程序,我想知道是否有办法做到这一点。我安装了Windows Phone 7.8并拥有最新的SDK。我正在寻找这个功能,支持所有三种磁贴尺寸并进行更新。
谢谢!
更新
Public Shared Sub CreateTile(uri As Uri, tiledata As ShellTileData, usewide As Boolean)
Dim shellTileType As Type = Type.[GetType]("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone")
Dim Createmethod As MethodInfo = shellTileType.GetMethod("Create", {GetType(Uri), GetType(ShellTileData), GetType(Boolean)})
Createmethod.Invoke(Nothing, New Object() {uri, tiledata, usewide})
End Sub
Private Shared Sub SetProperty(instance As Object, name As String, value As Object)
Dim setMethod = instance.[GetType]().GetProperty(name).GetSetMethod()
setMethod.Invoke(instance, New Object() {value})
End Sub
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 FS As IsolatedStorageFileStream = Storage.OpenFile("MyNote/SavedNotes/" & data.FileNameX, FileMode.Open, FileAccess.Read)
Dim FETime As String = Storage.GetCreationTime("MyNote/SavedNotes/" & data.FileNameX).ToString("dd/mm/yyyy h:mmtt")
Using SR As New StreamReader(FS)
Dim newTile As ShellTile = ShellTile.ActiveTiles.FirstOrDefault(Function(x) x.NavigationUri.ToString().Contains("/CreateNote.xaml?tile=" & data.FileNameX))
If newTile Is Nothing Then
Dim tileDataType As Type = Type.[GetType]("Microsoft.Phone.Shell.IconicTileData, Microsoft.Phone")
Dim IconicTileData As ShellTileData = DirectCast(tileDataType.GetConstructor(New Type() {}).Invoke(Nothing), ShellTileData)
SetProperty(IconicTileData, "Title", data.FileNameX)
SetProperty(IconicTileData, "BackgroundColor", Colors.Transparent)
SetProperty(IconicTileData, "IconImage", New Uri("\Assets\202.png", UriKind.Relative))
SetProperty(IconicTileData, "SmallIconImage", New Uri("\Assets\110.png", UriKind.Relative))
SetProperty(IconicTileData, "WideContent1", SR.ReadLine)
SetProperty(IconicTileData, "WideContent2", SR.ReadLine)
SetProperty(IconicTileData, "WideContent3", FETime)
CreateTile(New Uri("/CreateNote.xaml?Titletxt=" & data.FileNameX & "&Bodytxt=" & data.Description, UriKind.Relative), IconicTileData, True)
Else
MessageBox.Show("The tile has been pin to start!")
End If
End Using
End Sub
到目前为止,我设法创造它并且它有效!但是有一个问题。用户单击磁贴后,将转到用户查看它的CreateNote页面。但是用户无法控制文件,因为无法编辑或保存文件或任何内容。它基本上只是一个观点。如何制作它以便当用户点击磁贴时,它会进入“CreateNote”页面并启用所有功能?
答案 0 :(得分:1)
看一下Windows Phone的资源,他们真的很棒。
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj720574(v=vs.105).aspx