Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7952465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:52:12+00:00 2026-06-04T02:52:12+00:00

I had this code working before, but have somehow deleted it as I was

  • 0

I had this code working before, but have somehow deleted it as I was trying to get something else fixed.

So I have a list which is bound as a View model, and the list has three lines on it.

I want to be able to click on the list, get the value of the third line on another page and use that value.

Here is the code for the selection of the list

private void List_SelectionChanged(object sender, SelectionChangedEventArgs e)
{

        // If selected index is -1 (no selection) do nothing
        if (List.SelectedIndex == -1)
            return;

        // Navigate to the new page
        NavigationService.Navigate(new Uri("/Route.xaml?selectedItem=" + List.SelectedIndex, UriKind.Relative));

        string urlWIthData = string.Format("/Route.xaml?name={0}", " ");
        this.NavigationService.Navigate(new Uri(urlWIthData, UriKind.Relative));
        // Reset selected index to -1 (no selection)
        List.SelectedIndex = -1;
}

Then, on the route page I want to be able to get the value and use the value line three….

How do I do this?

EDIT:

so this one part of the list:

this.Items.Add(new ItemViewModel() { LineOne = "Images/1.png", LineTwo = "Whitehawk - County   
Hospital - City Centre - Hove - Portslade - Mile Oak", LineThree = "1 Whitehawk - Mile Oak", 
LineFour = "1 Mile Oak - Whitehawk", LineFive = "1149" });

I Display the list on one page :

 <ListBox Margin="6,6,7,6" ItemsSource="{Binding Items}" Name="List" OpacityMask="#FFD38648" FontSize="26" SelectionChanged="List_SelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="0,0,0,17" DataContext="{Binding}">
                        <Image Name="Images" Source="{Binding LineOne}">
                        </Image>
                        <TextBlock Text="{Binding LineTwo}" Style="{StaticResource PhoneTextSubtleStyle}" Name="textblock3"></TextBlock>
                                             </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:52:13+00:00Added an answer on June 4, 2026 at 2:52 am

    You can cast the list’s SelectedItem to type Item and get the value from there:

    private void List_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
           // If selected index is -1 (no selection) do nothing
            if (List.SelectedIndex == -1)
                return;
    
           // Here's the codes -----------------------
    
           var item = Items.SelectedItem as Item;
           if(item == null) //cast didn't work
                return;
    
           var lineThree = item.LIneThree;
    
           // end of the codes -----------------------
    
            // Navigate to the new page
            NavigationService.Navigate(new Uri("/Route.xaml?selectedItem=" + List.SelectedIndex, UriKind.Relative));
    
            string urlWIthData = string.Format("/Route.xaml?name={0}", " ");
            this.NavigationService.Navigate(new Uri(urlWIthData, UriKind.Relative));
            // Reset selected index to -1 (no selection)
            List.SelectedIndex = -1;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So basically this code was working fine before. I had some computer issues and
I know this question was asked before but I have the following simple code
I had this working in an old code that I didn’t end up using...
I had tested this code: http://support.microsoft.com/kb/316383 It works, but a Word application is opened
Ok, so I had this working just fine before making a few controller additions
I had asked this question once before but has had 0 attention and the
I've updated active_admin to version 0.3.0 to get internationalization working. But I have problems
I asked this question before but that time the issue was that I had
I though I had solved this problem, but it is back: Code generation for
I have this login code, which works last night before I slept. Nobody used

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.