Click here to Skip to main content
15,867,453 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"/>
                        <TextBlock Text="{Binding mark}"
                                    Margin="0,10,22,0"
                                 FontSize="13" 
                           FontStyle="Italic" 
                           FontWeight="Bold"
                           Foreground="#ff4d94"
                                  TextAlignment="Center"
                                   Height="36"
                                   Width="60"/>
                        <TextBlock Text="{Binding mark1}"
                                    Margin="0,10,25,0"
                                 FontSize="13" 
                           FontStyle="Italic" 
                           FontWeight="Bold"
                           Foreground="#ff4d94"
                                  TextAlignment="Center"
                                   Width="60"
                                   Height="36" />

                        <TextBlock Text="{Binding mark2}"
                                   Margin="0,10,32,10"
                                 FontSize="13" 
                           FontStyle="Italic" 
                           FontWeight="Bold"
                           Foreground="#ff4d94"
                                  TextAlignment="Center"
                                   Height="36"
                                   Width="60"
                                   />

                    </StackPanel>
                </DataTemplate>

            </ListView.ItemTemplate>
        </ListView>


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 int mark { get; set; }
        public int mark1 { get; set; }
        public int mark2 { get; set; }
        public int 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, total = 0 });
            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 });


        }
Posted
Updated 29-Sep-22 7:18am
v2
Comments
Venki Vky 29-Sep-22 7:00am    
I need to display the total without clicking a button can any one have a idea

1 solution

public int total => mark + mark1 + mark2;

<TextBlock Text="{Binding total}"/>
 
Share this answer
 
Comments
Venki Vky 30-Sep-22 2:18am    
thank you bro for your help..!!

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