【问题标题】:WP7 - How do i add tiles to my app?WP7 - 如何向我的应用程序添加图块?
【发布时间】:2013-12-04 07:58:01
【问题描述】:

基本上,我几乎完成了这个用户保存笔记等的笔记应用程序。基本的笔记应用程序功能。我没有完全完成的原因是我只需要帮助我在我的应用程序中添加图块以获取注释。基本上,用户从菜单项中单击“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

目前这是创建磁贴的代码。尽管有一个问题,一旦创建了磁贴,它就会抛出异常并说“磁贴只能在应用程序处于前台时创建”,但它仍然继续并毫无问题地创建磁贴。我遇到的第二个错误是我需要一种更新磁贴的方法。我只是不知道怎么做。

谁能帮帮我?

【问题讨论】:

    标签: windows-phone-7 add tiles


    【解决方案1】:

    使用 Microsoft.Phone.Controls.Toolkit 中的 HubTile 控件创建磁贴 你可以试试这段代码: var shellTileData = new StandardTileData { BackgroundImage = new Uri("图像路径", UriKind.RelativeOrAbsolute), BackContent = "xyz"

                };
                var tile = ShellTile.ActiveTiles.First();
                tile.Update(shellTileData);
    

    【讨论】:

    • 您好,谢谢您,但是更新磁贴呢?我该怎么做?
    • 你有解决办法吗??
    • 嘿,我已经添加了代码,我尝试调试它,但出现错误。它突出显示 HubTile.Name、Hubtile.Title 和 Hubtile.Message。说“对非共享成员的引用需要对象引用。”知道如何解决这个问题吗?
    • 您是否在 xaml 部分中使用了 hubtile 控件?
    • 没有。我正在使用默认的 StandardTileData
    猜你喜欢
    • 2010-11-05
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    • 2013-05-22
    • 2022-01-05
    • 1970-01-01
    • 2012-03-13
    • 1970-01-01
    相关资源
    最近更新 更多