This is a migrated thread and some comments may be shown as answers.

Determine which item is currently shown

2 Answers 38 Views
SlideView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
dnalabs
Top achievements
Rank 1
dnalabs asked on 26 Feb 2014, 07:54 PM
Hi,

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">
10.             
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.

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Stanoev
Telerik team
answered on 03 Mar 2014, 10:21 AM
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.

Regards,
Kiril Stanoev
Telerik
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.
0
dnalabs
Top achievements
Rank 1
answered on 04 Mar 2014, 06:44 PM
It worked. Thank you so much!
Tags
SlideView
Asked by
dnalabs
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
dnalabs
Top achievements
Rank 1
Share this question
or