This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--TitlePanel contains the name of the application and page title--> | |
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> | |
<TextBlock Text="Listbox Databinding" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/> | |
<TextBlock Text="Listbox" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> | |
</StackPanel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListBox x:Name="mylistbox"> | |
<ListBox.ItemTemplate> | |
<DataTemplate> | |
<Grid Height="52" Width="auto"> | |
<TextBlock x:Name="nameblock" Text="{Binding name}" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Height="41" Width="331" FontSize="30" Margin="10,0,0,0" /> | |
<TextBlock x:Name="marksblock" Text="{Binding marks}" HorizontalAlignment="Left" Margin="391,0,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="41" Width="55" FontSize="30" /> | |
</Grid> | |
</DataTemplate> | |
</ListBox.ItemTemplate> | |
</ListBox> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Sample data to be used in the listbox | |
string[] studentnames = new string[8] { "Aalap", "Alex", "Aman", "Bharat", "Chetan", "Chitransh", "Vaibhav", "Vivek" }; | |
int[] studentmarks = new int[8] { 82, 78, 84, 56, 98, 94, 95, 97 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void firstmethod() | |
{ | |
//create a list of Resultclass | |
List<Resultclass> mylist = new List<Resultclass>(); | |
for (int i = 0; i < 8; i++) | |
{ | |
//Create a new object of Result class | |
Resultclass obj = new Resultclass(); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void secondmethod() | |
{ | |
for (int i = 0; i < 8; i++) | |
{ | |
//Create a new object of Result class | |
Resultclass obj = new Resultclass(); | |
//add the corresponding data from the sample array | |
obj.name = studentnames[i]; | |
obj.marks = studentmarks[i]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Public class | |
public class Resultclass | |
{ | |
public string name { get; set; } | |
public int marks { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--TitlePanel contains the name of the application and page title--> | |
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28"> | |
<TextBlock Text="Listbox Databinding" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/> | |
<TextBlock Text="Hub tiles" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/> | |
</StackPanel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ListBox x:Name="mylistbox" Margin="10,0,0,97"> | |
<ListBox.ItemsPanel> | |
<ItemsPanelTemplate> | |
<toolkit:WrapPanel Orientation="Horizontal"/> | |
</ItemsPanelTemplate> | |
</ListBox.ItemsPanel> | |
<ListBox.ItemTemplate> | |
<DataTemplate> | |
<StackPanel Height="190" Width="190" HorizontalAlignment="Left" VerticalAlignment="Top"> | |
<toolkit:HubTile Title="{Binding title}" Notification="{Binding notification}" Source="{Binding source}" GroupTag="{Binding tag}" Height="173" Width="173" Margin="0,8,0,0" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Tile class so as to provide data source for the mylistbox | |
public class Tileclass | |
{ | |
public string title { get; set; } | |
public string notification { get; set; } | |
public string source { get; set; } | |
public string tag { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Arrays to provide sample data | |
string[] arrayoftitle = new string[6] {"Flipkart","Snapdeal","Jabong","ebay","Amazon","HD" }; | |
string[] arrayofnotification = new string[6] { "Notify 1", "Notify 2", "Notify 3", "Notify 4", "Notify 5", "Notify 6" }; | |
string[] imagesource = new string[6] { "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg" }; | |
//The above sample images have been added into a folder called images in the project file |