Step 3 : The MainPage.xaml file is as in the following code:
Code :
<Page
x:Class="App1.MainPage"
IsTabStop="false"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App17"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="Red">
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".333*"></ColumnDefinition>
<ColumnDefinition Width=".233*"></ColumnDefinition>
<ColumnDefinition Width=".233*"></ColumnDefinition>
<ColumnDefinition Width=".333*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height=".083*"></RowDefinition>
<RowDefinition Height=".033*"></RowDefinition>
<RowDefinition Height=".333*"></RowDefinition>
<RowDefinition Height=".133*"></RowDefinition>
<RowDefinition Height=".333*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="3"
Text="LINQ in Metro Style Application" FontSize="30"
FontWeight="ExtraBold">
</TextBlock>
<TextBlock Grid.Column="1" Grid.Row="1" Text="Title of the Book"
FontSize="20" FontWeight="ExtraBold">
</TextBlock>
<TextBlock Grid.Column="2" Grid.Row="1" Text="Releasing Date of the Book"
FontSize="20" FontWeight="ExtraBold">
</TextBlock>
<GridView x:Name="gridview1" FontSize="10" FontWeight="Bold" Grid.Column="1" Grid.Row="2" >
</GridView>
<GridView x:Name="gridview2" FontSize="10" FontWeight="Bold" Grid.Column="2" Grid.Row="2" >
</GridView>
</Grid>
</Page>
Step 4 : Add the class Books.cs to our project to be used as the data source:
Code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace App1
{
class Books
{
public string ID { get; set; }
public string Title { get; set; }
public decimal Price { get; set; }
public DateTime DateOfRelease { get; set; }
public static List<Books> GetBooks()
{
List<Books> list = new List<Books>();
list.Add(new Books
{
ID = "001",
Title = "Programming in C#",
Price = 634.76m,
DateOfRelease = Convert.ToDateTime("2010-02-05")
});
list.Add(new Books
{
ID = "002",
Title = "Learn Jave in 30 days",
Price = 250.76m,
DateOfRelease = Convert.ToDateTime("2011-08-15")
});
list.Add(new Books
{
ID = "003",
Title = "Programming in ASP.Net 4.0",
Price = 700.00m,
DateOfRelease = Convert.ToDateTime("2011-02-05")
});
list.Add(new Books
{
ID = "004",
Title = "VB.Net Made Easy",
Price = 500.99m,
DateOfRelease = Convert.ToDateTime("2011-12-31")
});
list.Add(new Books
{
ID = "005",
Title = "Programming in C",
Price = 314.76m,
DateOfRelease = Convert.ToDateTime("2010-02-05")
});
list.Add(new Books
{
ID = "006",
Title = "Programming in C++",
Price = 456.76m,
DateOfRelease = Convert.ToDateTime("2010-02-05")
});
list.Add(new Books
{
ID = "007",
Title = "Datebase Developement",
Price = 1000.76m,
DateOfRelease = Convert.ToDateTime("2010-02-05")
});
return list;
}
}
}