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

SlideView Item sellection tap event

5 Answers 41 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.
Joaquim
Top achievements
Rank 1
Joaquim asked on 02 Oct 2014, 06:16 PM
I have a SlideView with several items inside and I want to navigate to a new page depending of the item selected.
For example, I tap item1 and it navigates to page1 but if I tap the item2 it should navigate to page2, and so on...

Here is my xaml:
<telerikPrimitives:RadSlideView x:Name="slideViewApps" Margin="0" ItemsSource="{Binding}" ItemRealizationMode="ViewportItem" CacheMode="BitmapCache" Tap="slideViewApps_Tap" >                              
                <telerikPrimitives:RadSlideView.ItemTemplate>
                    <DataTemplate>
                        <Grid>                      
                            <Image Source="{Binding AppsImagePath}" Stretch="None" Grid.Row="1" Margin="0"/>
                            <TextBlock Text="{Binding AppsTitle}" FontSize="{StaticResource PhoneFontSizeExtraLarge}" Margin="24,280,0,0"/>
                        </Grid>
                    </DataTemplate>
                </telerikPrimitives:RadSlideView.ItemTemplate>
                <telerikPrimitives:RadSlideView.ItemPreviewTemplate>
                    <DataTemplate>
                        <TextBlock HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Text="{Binding AppsDescription}"
                       FontSize="{StaticResource PhoneFontSizeLarge}"/>
                    </DataTemplate>
                </telerikPrimitives:RadSlideView.ItemPreviewTemplate>

and my C#
public StartPage()
       {
           InitializeComponent();
 
           string[] appnames = { "Shazam", "Coachs's Eye", "Files and Folders Pro" };
           string[] gamenames = { "Fifa 15", "Poker", "Tetris" };
 
           List<ViewModel> items = new List<ViewModel>();
 
           for (int i = 1; i <= 3; i++)
           {
               ViewModel model = new ViewModel()
               {
                   AppsTitle = "#" + i + " " + appnames[i-1],
                   AppsImagePath = "ImagesApps/" + i + ".jpg",
                   AppsDescription = "best app of the week " + "# " + i,
 
                   GamesTitle = "#" + i + " " + gamenames[i - 1],
                   GamesImagePath = "ImagesGames/" + i + ".jpg",
                   GamesDescription = "best game of the week " + "# " + i
               };
 
               items.Add(model);
           }
 
           this.DataContext = items;
 
       }
 
       private void slideViewApps_Tap(object sender, GestureEventArgs e)
       {
               ////////jump to a page depending of selection ???????????

           this.NavigationService.Navigate(new Uri("/AppsView/App1.xaml", UriKind.RelativeOrAbsolute));
        }
 
 
       public class ViewModel
       {
           public string AppsTitle
           {
               get;
               set;
           }
 
           public string AppsImagePath
           {
               get;
               set;
           }
 
           public string AppsDescription
           {
               get;
               set;
           }
 
           public string GamesTitle
           {
               get;
               set;
           }
 
           public string GamesImagePath
           {
               get;
               set;
           }
 
           public string GamesDescription
           {
               get;
               set;
           }
       }

Any idea how can I perform this.
Thanks in advance,
Joaquim

5 Answers, 1 is accepted

Sort by
0
Joaquim
Top achievements
Rank 1
answered on 04 Oct 2014, 11:48 AM
Is there anyone that could help me on this?
Thanks
0
Tsvyatko
Telerik team
answered on 06 Oct 2014, 01:32 PM
Hello Joaquim,

From the code snippet posted it seems that you have bound RadSlideView to list of view models. Thus you can use slideView.SelectedItem  in slideViewApps_Tap to get currently selected viewmodel and navigate to the appropriate page.

Regards,
Tsvyatko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Joaquim
Top achievements
Rank 1
answered on 06 Oct 2014, 08:12 PM
Hello Tsvyatko,

Thanks for your answer. I am having some difficulties to get the currently selected viewmodel item. Could you please be so kind to share the code that I have to use in the slideViewApps_Tap based on my code snippet that allows me to navigate to a particularly page.

Thanks in advance and have a nice day.
Joaquim


0
Tsvyatko
Telerik team
answered on 09 Oct 2014, 02:01 PM
Hello Joaquim,

Please find the attached sample project demonstrating how you can navigate between the pages based on selected item.

Regards,
Tsvyatko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Joaquim
Top achievements
Rank 1
answered on 09 Oct 2014, 09:06 PM
Hi Tsvyatko,

Works like a charm.
A million thanks.
Tags
SlideView
Asked by
Joaquim
Top achievements
Rank 1
Answers by
Joaquim
Top achievements
Rank 1
Tsvyatko
Telerik team
Share this question
or