Reputation: 487
Basically everything was going fine until i clicked my app's secondary tile and nothing had been updated. What i'm currently working on right now is a note app and one of the main functionality is pinning the note to the start screen.
The problem is that once the tile gets created it's assigned a unique random ID so that if the content of the tile needs changing that id will be used to find that tile IF it's pinned and update so. The Unique ID is generated once the user clicks save on a new note and will not change.
Basically It does that part all right it's just that once i click the secondary app it takes me to a page with the parameters which i initially created with not the ones i modified.
e.g. I create a note and the TITLE: Hello and MESSAGE: HI!!!. and pin it to the start. Now the tile shows me the title and message. I decide to make changes to the note. I change the title to: yes and message to: no. i open up the app and make the changes to the note and everything gets updated. Now i have the modified note which is automatically updated. Now the tile shows me the modified note. so the tiles content will be yes and no.
But i decide to view the note by clicking the tile. It takes me to the page but instead of showing the modified content of the note, it shows me the initial note text which is Hello and Hi!! rather than Yes and No.
My Sourcecode for the creating and updating is:
Dim contextMenuListItem As ListBoxItem = DirectCast(ItemsList.ItemContainerGenerator.ContainerFromItem(DirectCast(sender, MenuItem).DataContext), ListBoxItem)
Dim item As SampleData1 = DirectCast(contextMenuListItem.Content, SampleData1)
Dim TileToFind As ShellTile = ShellTile.ActiveTiles.FirstOrDefault(Function(x) x.NavigationUri.ToString().Contains("parameter2=" & item.ID))
If TileToFind Is Nothing Then
Dim TileData As New IconicTileData() With { _
.Title = item.Name, _
.WideContent1 = item.Name, _
.WideContent2 = item.Description, _
.WideContent3 = item.ID, _
.SmallIconImage = New Uri("Assets/Tiles/IconicTileSmall.png", UriKind.Relative), _
.IconImage = New Uri("Assets/Tiles/IconicTileMediumLarge.png", UriKind.Relative), _
.BackgroundColor = Colors.Transparent}
ShellTile.Create(New Uri("/CreateNote.xaml?parameter=" & TileData.Title.ToString & "¶meter1=" & TileData.WideContent2.ToString & "¶meter2=" & TileData.WideContent3.ToString, UriKind.Relative), TileData, True)
Else
Dim TileData As New IconicTileData() With { _
.Title = item.Name, _
.WideContent1 = item.Name, _
.WideContent2 = item.Description, _
.SmallIconImage = New Uri("Assets/Tiles/IconicTileSmall.png", UriKind.Relative), _
.IconImage = New Uri("Assets/Tiles/IconicTileAssets/IconicTileMediumLarge.png", UriKind.Relative), _
.BackgroundColor = Colors.Transparent}
TileToFind.Update(TileData)
End If
VIDEO showing what i mean: https://www.youtube.com/watch?v=xsedPk7YKdw
ADDED =================================================================================
Code which creates the tile with the navigation parameters:
ShellTile.Create(New Uri("/CreateNote.xaml?parameter=" & TileData.Title.ToString & "¶meter1=" & TileData.WideContent2.ToString & "¶meter2=" & TileData.WideContent3.ToString, UriKind.Relative), TileData, True)
On the CreateNote Page the parameters:
Protected Overrides Sub OnNavigatedTo(ByVal e As System.Windows.Navigation.NavigationEventArgs)
MyBase.OnNavigatedTo(e)
Dim parameter As String = String.Empty
Dim parameter1 As String = String.Empty
Dim parameter2 As String = String.Empty
If NavigationContext.QueryString.TryGetValue("parameter", parameter) Then
Me.Title.Text = parameter
OldFName.Text = parameter
End If
If NavigationContext.QueryString.TryGetValue("parameter1", parameter1) Then
Me.Message.Text = parameter1
End If
If NavigationContext.QueryString.TryGetValue("parameter2", parameter2) Then
Me.IDG.Text = parameter2
End If
End Sub
Do you see my problem?
Upvotes: 1
Views: 205
Reputation: 89325
Here is the problem :
Your application will display information passed to Uri parameters, but in the update Tile operation you leave the Tile Uri not updated with new parameter values -only Tile's data being updated-.
And possible solution :
Since NavigationUri property of ShellTile is read-only, I assume that updating Tile's Uri is not supported. Therefore I suggest an alternative to always create a new Tile, then remove old Tile if it already exist.
Upvotes: 1