Deleting the content of single cells

Dec 3, 2008 at 4:46 PM
Hello, I've tried different approaches to clear the contents of a single cell in a DataGrid (in a generic Window.PreviewKeyUp event), but still I couldn't do it.

I've tried clearing the value of the ContentProperty dependency property, which clears it from the grid, but not from the bound element, I've tried to use BindingOperations to get the BindingExpression, but had no luck with that either.

I've tried many other things that I don't remember now, I know this is probably a symptom of my lack of knowledge about WPF...could anyone tell me how I can do this?

Dec 4, 2008 at 2:00 PM
Edited Dec 4, 2008 at 2:02 PM
I've found what I needed to do.

Looking at this thread, I've learned how to get hold of the BindingExpression associated with the cell's TextBlock, changed that text to an empty string, and called UpdateSource() on the BindingExpression.

Thanks to CorpPeon and vinisibal for that thread! =)