locked
How to know the name of current image in FlipView (VB.NET)?

    Question

  • Hello, will someone please help me with what I am trying to do?

    I intend to determine the name of currently selected image in my FlipView Control in VB.NET, this is the "pseudocode" of what I am trying to do:

    Button
            If FlipView.CurrentSelectedItem = "bag.jpg" Then
    label.text = "Current item: Bag"
            End If
    End Button

    Thank you in advance!

    Sunday, December 07, 2014 10:26 AM

Answers

  • Hi Abien,

    When you bind collection array to FlipView, you can use FlipView.SelectedItem property to get the selected item in collection array. Please try the following code snippet and let me know the result.

    1, define a new class.

    Private images As List(Of ImageItem)

    Public Sub New()

            Me.InitializeComponent()

    End Sub

    Private Sub Page_Loaded(sender As Object, e As RoutedEventArgs)

            images = New List(Of ImageItem)()

            ' init the images

            '.................

            flipview1.ItemsSource = images

    End Sub2, bind collection array to FlipView control.

    Private images As List(Of ImageItem)

    Public Sub New()

            Me.InitializeComponent()

    End Sub

    Private Sub Page_Loaded(sender As Object, e As RoutedEventArgs)

            images = New List(Of ImageItem)()

            ' init the images

            '.................

            flipview1.ItemsSource = images

    End Sub

    3, get the current image

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)

            Dim image As ImageItem = TryCast(flipview1.SelectedItem, ImageItem)

            label.Text = image.Name

    End Sub

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Monday, December 08, 2014 5:44 AM
    Moderator