Question

Does anyone know how I can open up a Coding4Fun User Control when I tap on a particular item in my LongListSelector. I want some items to take me to different pages but also for some items to open up a User Control.

Partial Public Class Station_Chooser
    Inherits PhoneApplicationPage

    Public Sub New()
        InitializeComponent()

        Dim source As New List(Of AStations)()
        source.Add(New AStations("Aldgate", "Fare zone 1"))
        source.Add(New AStations("Aldgate East", "Fare zone 1"))
        source.Add(New AStations("Angel", "Fare zone 1"))
        source.Add(New AStations("Baker Street", "Fare zone 1"))
        source.Add(New AStations("Bank", "Fare zone 1"))
        source.Add(New AStations("Barbican", "Fare zone 1"))
        source.Add(New AStations("Bayswater", "Fare zone 1"))
        source.Add(New AStations("Blackfriars", "Fare zone 1"))
        source.Add(New AStations("Bond Street", "Fare zone 1"))
        source.Add(New AStations("Borough", "Fare zone 1"))

        Dim DataSource As List(Of AlphaKeyGroup(Of AStations)) = AlphaKeyGroup(Of AStations).CreateGroups(source, System.Threading.Thread.CurrentThread.CurrentUICulture, Function(s As AStations)
                                                                                                                                                                              Return s.Station
                                                                                                                                                                          End Function, True)
        AllStations.ItemsSource = DataSource
    End Sub

    Public Class AStations
        Public Property Station() As String
            Get
                Return m_Station
            End Get
            Set(value As String)
                m_Station = value
            End Set
        End Property
        Private m_Station As String

        Public Property FareZone() As String
            Get
                Return m_FareZone
            End Get
            Set(value As String)
                m_FareZone = value
            End Set
        End Property
        Private m_FareZone As String

        Public Property Link() As String
            Get
                Return m_Link
            End Get
            Set(value As String)
                m_Link = value
            End Set
        End Property
        Private m_Link As String

        Public Sub New(station As String, farezone As String, link As String)
            Me.Station = station
            Me.FareZone = farezone
            Me.Link = link
        End Sub
    End Class
End Class
Was it helpful?

Solution

Sure this a "quick fix". I am assuming AllStations is your LongListSelector. So find the code for it in XAML.
OR

Go to proprities windows, and click on event handlers (it has a lightning icon). Scroll down to SelectionChanged even, and double click on the textbox. It will create an event handler in the code. it will look something like this.

 private void AllStations_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        //your logic

        }
    }

Now you can handle the event. So all you have to do when you test on your emulator or device, is to just tap on the item.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top