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
//Function to add the items into the listbox | |
public void addtheitems() | |
{ | |
for (int i = 0; i < 6; i++) | |
{ | |
//Create a new object | |
Tileclass obj = new Tileclass(); | |
//add the title,notification and source from the sample data | |
obj.title = arrayoftitle[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
//Event handler for freezebutton click | |
private void freezetilesbuttonclick(object sender, RoutedEventArgs e) | |
{ | |
//This line will freeze the animation of Hub tiles | |
HubTileService.FreezeGroup("Tiles"); | |
} | |
//Event handler for unfreezebutton click | |
private void Unfreezetilesbuttonclick(object sender, RoutedEventArgs e) | |
{ |
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
xmlns:toolkit=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit” |
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 Selected Item" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/> | |
<TextBlock Text="List box" 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="0,0,0,101" SelectionChanged="Selectionchanged_Eventhandler_of_Listbox"> | |
<ListBox.ItemTemplate> | |
<DataTemplate> | |
<Grid Height="80" VerticalAlignment="Top"> | |
<TextBlock x:Name="nameblock" Text="{Binding name}" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Height="57" Width="236" FontSize="36" Margin="10,10,0,0" /> | |
<Button Content="Marks" HorizontalAlignment="Left" Margin="275,0,0,0" VerticalAlignment="Top" Height="80" Width="181" Click="Marks_button_click"/> | |
</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
//Class which acts as a data source for the databound mylistbox | |
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
//Arrays to provide sample data to listbox | |
string[] arrayofnames = new string[6] { "Alex", "Fred", "James", "Aman", "Ankur", "Vaibhav" }; | |
int[] arrayofmarks = new int[6] { 80, 82, 98, 76, 94, 100 }; |
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
//Making a sample list from the data given above | |
public void makeasamplelist() | |
{ | |
for (int i = 0; i < 6; i++) | |
{ | |
//Create a new instace of the class | |
Resultclass obj = new Resultclass(); | |
//Add the sample data | |
obj.name = arrayofnames[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
//Selection changed event handler for listbox | |
private void Selectionchanged_Eventhandler_of_Listbox(object sender, SelectionChangedEventArgs e) | |
{ | |
//Get the data object that represents the current selected item | |
Resultclass myobject = (sender as ListBox).SelectedItem as Resultclass; | |
//Checking whether that it is not null | |
if (myobject != null) | |
{ | |
//Now you can get the name and marks of selected student from the myobject |
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
//Event handler for marks button given in the mylisybox | |
private void Marks_button_click(object sender, RoutedEventArgs e) | |
{ | |
//Get the data object that represents the current selected item | |
Resultclass myobject = (sender as Button).DataContext as Resultclass; | |
//Get the selected ListBoxItem container instance of the item whose marks button is pressed | |
ListBoxItem pressedItem = this.mylistbox.ItemContainerGenerator.ContainerFromItem(myobject) as ListBoxItem; | |
//Checks whether it is not null |