Obtaining data from any UI element it is bound to
When a user who is working with your application performs a certain action, it's often essential to know on what object this action will be executed. For example, if a user clicks on a Delete button on an item, it's essential that you know which item is clicked so that you can write the correct code to delete that item. Also, when a user wants to edit an item in a list, it's necessary that you—the programmer—know which item in the list the user wants to edit.
In Silverlight, there is a very easy mechanism called DataContext
that helps us in this task. In this recipe, we're going to use the DataContext
to get the data when we need it.
Getting ready
If you want to follow along with this recipe, you ...
Get Silverlight 4 Data and Services Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.