Click here to Skip to main content
15,881,638 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<pre> <ListView x:Name="content"  Grid.Row="1" SelectionMode="Single" SelectionChanged="content_SelectionChanged"  ItemsSource="{x:Bind Customers}"
    HorizontalAlignment="Stretch"
    VerticalAlignment="Top" MinWidth="44" Background="Transparent">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="x:Bind">

                    <StackPanel  Margin="0,0,0,5" x:Name="row2"  Background="White" Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="auto">
                   
                        <TextBlock Text="{Binding Name}"
                                   Margin="3,10,36,0"
                           FontSize="13" 
                           FontStyle="Italic" 
                           FontWeight="Bold"
                           Foreground="DarkBlue"
                                   Height="36"
                                   Width="63"/>

                        <TextBlock Text="{Binding age}"
                                    Margin="0,10,3,0"
                                  FontSize="13" 
                           FontStyle="Italic" 
                           FontWeight="Bold"
                           Foreground="DarkBlue"
                                   Height="36"
                                   Width="50"/>


What I have tried:

C#
<pre> public class Customer
    {
       public object  Id   { get; set; }
        public object Name { get; set; }
        public object age { get; set; }
        public object mark { get; set; }
        public object mark1 { get; set; }
        public object mark2 { get; set; }
        public object total { get; set; }
    }

    public sealed partial class MainPage : Page
    {

        public ObservableCollection<Customer> Customers { get; } = new ObservableCollection<Customer>();


        public MainPage()
        {
            this.InitializeComponent();
            Customers.Add(new Customer() { Id = 1, Name = "NAME 1", age = 20, mark = 70, mark1 = 43, mark2 = 55 });
            Customers.Add(new Customer() { Id = 2, Name = "NAME 2", age = 20, mark = 46, mark1 = 53, mark2 = 52 });
            Customers.Add(new Customer() { Id = 3, Name = "NAME 3", age = 20, mark = 50, mark1 = 63, mark2 = 75 });
            Customers.Add(new Customer() { Id = 4, Name = "NAME 4", age = 20, mark = 84, mark1 = 73, mark2 = 85 });
            Customers.Add(new Customer() { Id = 5, Name = "NAME 5", age = 20, mark = 70, mark1 = 43, mark2 = 55 });
            Customers.Add(new Customer() { Id = 6, Name = "NAME 6", age = 20, mark = 46, mark1 = 53, mark2 = 52 });
            Customers.Add(new Customer() { Id = 7, Name = "NAME 7", age = 20, mark = 50, mark1 = 63, mark2 = 75 });
            Customers.Add(new Customer() { Id = 8, Name = "NAME 8", age = 20, mark = 84, mark1 = 73, mark2 = 85 });
            Customers.Add(new Customer() { Id = 9, Name = "NAME 9", age = 20, mark = 70, mark1 = 43, mark2 = 55 });
            Customers.Add(new Customer() { Id = 10, Name = "NAME 10", age = 20, mark = 46, mark1 = 53, mark2 = 52 });
            Customers.Add(new Customer() { Id = 11, Name = "NAME 11", age = 20, mark = 50, mark1 = 63, mark2 = 75 });
            Customers.Add(new Customer() { Id = 12, Name = "NAME 12", age = 20, mark = 84, mark1 = 73, mark2 = 85 });
            Customers.Add(new Customer() { Id = 13, Name = "NAME 13", age = 20, mark = 70, mark1 = 43, mark2 = 55 });
            Customers.Add(new Customer() { Id = 14, Name = "NAME 14", age = 20, mark = 46, mark1 = 53, mark2 = 52 });
            Customers.Add(new Customer() { Id = 15, Name = "NAME 15", age = 20, mark = 50, mark1 = 63, mark2 = 75 });
            Customers.Add(new Customer() { Id = 16, Name = "NAME 16", age = 20, mark = 84, mark1 = 73, mark2 = 85 });

        }

        private void content_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
          
            Frame.Navigate(typeof(BlankPage2));

        }
    }
Posted
Updated 3-Oct-22 1:14am
v4
Comments
Venki Vky 3-Oct-22 4:01am    
**DETAILS OF THE CODE ** Hi guys i am working with (universal windows platform (UWP)) I have created a list on the main page. And I have given the data of the list on the main page.cs, (how can I display the only one student details on the black page by selecting the name of the student ) EXAMPLE: there is an app that contains a list that has the student's name the task is if I select a student in the list example (name 1) the app should navigate to another page example (black page 1) in that black page I should have the name of the student, age of the student, marks of the student, In the above code given the data of student. I need to display the name, age , and marks of a single student in black page
**SUBJECT**
I should display the a single student detail by id or name

1 solution

I GOT THE ANSWER
C#
private void content_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           Customer selectedItem = content.SelectedItem as Customer;

           Frame.Navigate(typeof(BlankPage2), selectedItem);
       }

<pre lang="XAML">protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            Customer customer = e.Parameter as Customer;

            this.DataContext = customer;
        }
 
Share this answer
 
Comments
Richard MacCutchan 3-Oct-22 7:31am    
Please do not write in BOLD CAPITALS, it looks like you are shouting, which is considered rude. Everyone here is quite capable of reading normal text.
Venki Vky 3-Oct-22 8:23am    
sorry about that i will not do it once again

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900