Determine which item is currently shown

Thread is closed for posting
3 posts, 1 answers
  1. dnalabs
    dnalabs avatar
    3 posts
    Member since:
    Jan 2014

    Posted 26 Feb 2014 Link to this post


    I am creating a very simple image slider using SlideView. I have three images and I simply display them one by one.
    This is my code:

    01.<telerikPrimitives:RadSlideView Grid.RowSpan="2"
    02.                                        AdjacentItemsPreviewMode="None"
    03.                                        IsLoopingEnabled="False"
    04.                                        Orientation="Horizontal"
    05.                                        x:Name="radSlideView"
    06.                                        ItemsSource="{Binding}"
    07.                                        ItemRealizationMode="ViewportItem"
    08.                                        Margin="-12"
    09.                                        CacheMode="BitmapCache">
    11.            <telerikPrimitives:RadSlideView.ItemTemplate>
    12.                <DataTemplate>
    13.                    <Image Source="{Binding ImagePath}"
    14.                           HorizontalAlignment="Center"
    15.                           VerticalAlignment="Center"/>
    16.                </DataTemplate>
    17.            </telerikPrimitives:RadSlideView.ItemTemplate>
    18.        </telerikPrimitives:RadSlideView>

    What I want to do is detect if the user has reached the last image. if yes, then display a button to close the slide view and navigate to another page.
    Please tell me how can I detect the image index currently being shown to the user or if the user has reached the last image of the slideview so that I can display my button.

  2. Answer
    Kiril Stanoev
    Kiril Stanoev avatar
    1512 posts

    Posted 03 Mar 2014 Link to this post

    Hi dnalabs,
    You can use the SelectionChanged of RadSlideView to achieve what you're looking for.
    Let's say you have a collection that holds your items.

    List<MyDataItem> items = new List<MyDataItem>();

    In the SelectionChanged event of RadSlideView, you can ask the collection (items) to give you the index of the currently selected item.

    private void RadSlideView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        MyDataItem item = (MyDataItem)e.AddedItems[0];
        int index = this.items.IndexOf(item);
        if (index == this.items.Count - 1)
            // the last item has been reached

    You can insert your logic for showing the button in the if statement.
    Let us know if this helps.

    Kiril Stanoev
    If you want to get updates on new releases, tips and tricks and sneak peek previews directly from the developers working on the UI for Windows Phone, subscribe to the blog feed now.
  3. dnalabs
    dnalabs avatar
    3 posts
    Member since:
    Jan 2014

    Posted 04 Mar 2014 in reply to Kiril Stanoev Link to this post

    It worked. Thank you so much!
Back to Top