Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi all!

I have datagrid which is bound to my datacollection. I represent my data trough (DataGridTemplateColumn) datatemplates. I have added events some of my datatemplates and events are handled in code.

The question is that how do I manipulate specifig cell information inside that event. For example if I click textbox cell which launches event, in that event my method returns string and I need to show it in that specifig textbox cell (and ofcource that data is also added into that dataclass which is represented that datagrid)

Hope you got idea :)

Cheers!
Posted

1 solution

You can use the Event Handler's argument.

Most of the Arguments are derived from the RoutedEventArgs which has OriginalSource property. The OrignalSource would have the control which raised that particular event. In you case, it would be the TextBox (My guess, unless you have implemented in a different way).
 
Share this answer
 
Comments
paleGegg0 11-Apr-11 2:44am    
Hi! I think I got it working but not sure is this way you suggested.

private void TextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
MyDataClass temp = (sender as TextBox).DataContext as MyDataClass;
sender = temp;
MyDataGrid.Items.Refresh();
}

anyway thanks for the tip :)!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900