In the Windows Phone 7.5 application I'm creating, I've got a problem with binding a navigationservice to a button. The button is inside a ListBox datatemplate in XAML, which is populated from codebehind from a JSON deserializer:
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
return;
}
List<JSON> newslistJson = JsonConvert.DeserializeObject<List<JSON>>(e.Result);
this.NewsList.ItemsSource = newslistJson;
}
The NewsList listbox is here populated via the code above, and a class file containing and the "getters" and "setters". However, inside the ListBox and it's DataTemplate, as stated earlier, there's a button:
<Button x:Name="toNewsSite" Grid.Row="1" Content="Read MoreĀ»" Height="auto" Width="auto" FontSize="19" Foreground="#FFFFFF"/>
This button should, via the first code snippet, navigate to each of the items' news_id, which is a string in the class file handling the public getters and setters.
So my dream scenario here would be, in codebehind, something like this inside the webClient_DownloadString...():
toNewsSite.NavigateService = ("TheNewPage.xaml/news?id={0}", JSON.news_id);
Aaand from there each of the news items in the listbox will have an individual button with a parameter stating which news_id it has, which will be fetched on the "TheNewPage" page.
Would this actually work?