There are some ways to do that. One of them shown in this SO question, maybe not the best or the most beautiful way but a very simple one.
Attach event handler for
SelectionChanged
, add command for navigating to new page in the handler, setSelectedItem = null
I assumed that the destination page is same page for any item selected, only different content/data displayed. You need to pass selected item's signature in the Uri parameter to enable destination page to display information accordingly. For example :
NavigationService.Navigate(New Uri("/nextpage.xaml?selectedStation=" & selectedItem.Station, UriKind.Relative))
UPDATE :
As you clarified that destination page will be different for each item, my previous answer still valid. Only the later part need to be modified, not using Uri parameter.
So this is what I think. Add another property in Glasgow
class, say it StationId
. Upon initialization :
//the second parameter is StationId value
source.Add(New Glasgow("Bridge Street", "BridgeStreet"))
Then name each page with pattern StationId.xaml, so page for Bridge Street should be BridgeStreet.xaml
. With that, in SelectionChanged
event handler you can navigate to corresponding page without using Select Case selectedItem.Station ...
:
NavigationService.Navigate(New Uri(selectedItem.StationId & ".xaml", UriKind.Relative))
Note : Having more then one properties in the model (Station
and StationId
in this case) require you to specify which property to display in LongListSelector
. Check this link to know how, if you don't know yet.