locked
Using Gridview to navigate thru pages

    Question

  • Hi all,

    in my App, on the mainpage, I have a gridview control with several items which represent the main menu.
    I use the "binding" to get my control values and then I make them accessible to the page with me.datacontext = 'datasource'.

    When click on any item menu, a new page is supposed to open. The name of the target page is also stored in the item source class and addressed with set and get.

    my problem is, I don't know how to access the page field programmatically.

    In other words, when the user clicks on a gridview item, I need to access the corresponding page field from the datasource and pass it to the me.frame.navigate(gettype())

    Private sub itemview_ItemClick(sender as object, e as ItemClickEventArgs)

          dim targetpage = >>>>>code here to retrieve the page from the datasource<<<<<

          me.frame.navigate(gettype(targetpage)) 

    end sub

    Thanks.

    Gianfranco

    Saturday, May 3, 2014 11:54 PM

All replies

  • Hi Gianfranco,

    Why do you need access the page field, if you go through the navigate api, should be able to find Navigate(TypeName, Object) method,where you can put your value into the object and accept it in next page by e.NavigationParameter.

    A more detail explanation can be found: Quickstart: Navigating between pagessection "Passing information between pages".

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, May 5, 2014 7:56 AM
    Moderator
  • Thank you James for your feedback.

    However, the reason why I want to store my pages in the gridview datasource is because I have several different pages, with different data content, for each item in my gridview control.

    So far, I bypassed the solution I would like to implement, by adding a selection change method to my gridview control and testing the itemGridView.selectedIndex to navigate to the corresponding page, but I have to statically spell all page names for each single itemIndex:

    Select Case itemGridView.selectedIndex

        Case Is = 0     'I know I am in gridview item 1

             'Navigate to pagename1'

       Case Is = 1       'I know I am in gridview item 2

            'Navigate to pagename2'

    and so on.....

    End Select

    It would be more practical to retrieve the page name from the data source, because if I had many pages, I would have to just add the item in the datasource without having to add more codes in my MainPage.

    Hope my explanation is clear.

    Thanks

    Gianfranco

    Monday, May 5, 2014 2:04 PM