Skip to content

Instantly share code, notes, and snippets.

View wtuts's full-sized avatar

Windows App Tutorials wtuts

View GitHub Profile
@wtuts
wtuts / Hub5.cs
Created June 24, 2014 19:58
Hub tiles-Part 2
//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];
@wtuts
wtuts / Hub6.cs
Created June 24, 2014 19:58
Hub tiles -Part 2
//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)
{
@wtuts
wtuts / Hub7.xaml
Created June 25, 2014 08:43
Hub tiles- Part 2
xmlns:toolkit=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit”
@wtuts
wtuts / file.xaml
Created June 25, 2014 13:24
Listbox Selected item
<!--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>
@wtuts
wtuts / file1.xaml
Last active August 29, 2015 14:03
Listbox Selected item
<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>
@wtuts
wtuts / file2.cs
Created June 25, 2014 13:50
Listbox Selected item
//Class which acts as a data source for the databound mylistbox
public class Resultclass
{
public string name { get; set; }
public int marks { get; set; }
}
@wtuts
wtuts / file3.cs
Created June 25, 2014 14:01
Listbox Selected item
//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 };
@wtuts
wtuts / file4.cs
Created June 25, 2014 14:02
Listbox selected item
//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];
@wtuts
wtuts / file5.cs
Created June 25, 2014 14:18
Listbox selected item
//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
@wtuts
wtuts / file6.cs
Last active August 29, 2015 14:03
Listbox Selected item
//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