Last active
August 29, 2015 14:03
-
-
Save wtuts/444d7c78d693dfaac17d to your computer and use it in GitHub Desktop.
Listbox Selected item
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 | |
if (pressedItem != null) | |
{ | |
//Now you can get the name and marks of selected student from the myobject | |
//Display the name and marks of Selected Student in the textblocks given below the listbox. | |
Studentnameblock.Text = myobject.name; | |
marksblock.Text = myobject.marks.ToString(); ; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment