SlideView Item sellection tap event

6 posts, 0 answers
  1. Joaquim
    Joaquim avatar
    7 posts
    Member since:
    Sep 2011

    Posted 02 Oct 2014 Link to this post

    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

  2. Joaquim
    Joaquim avatar
    7 posts
    Member since:
    Sep 2011

    Posted 04 Oct 2014 in reply to Joaquim Link to this post

    Is there anyone that could help me on this?
    Thanks
  3. DevCraft banner
  4. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 06 Oct 2014 Link to this post

    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.

     
  5. Joaquim
    Joaquim avatar
    7 posts
    Member since:
    Sep 2011

    Posted 06 Oct 2014 in reply to Tsvyatko Link to this post

    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


  6. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 09 Oct 2014 Link to this post

    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.

     
  7. Joaquim
    Joaquim avatar
    7 posts
    Member since:
    Sep 2011

    Posted 09 Oct 2014 in reply to Tsvyatko Link to this post

    Hi Tsvyatko,

    Works like a charm.
    A million thanks.
Back to Top
DevCraft banner