I have a data grid in my silverlight 4 application. I have also made a custom textbox that only takes numeric values and does a couple of other specific things. I also added a decimal dependency property on my custom control that I bind to, that pretty much returns a formatted version of Text that the control inherits from TextBox.
I then bind the datagrid's itemssource to an observablecolletion. I also added my custom control as one of the columns in the datagrid using DataGridTemplateColumn.
Everything works fine except the datagrid's virtualization. If I add an item to the dataGrid, edit the value in my custom Control, delete the row and then add a brand new row (a complete new instance) the value in my custom control is the value of the deleted row. And to clear up, it is not a binding mistake or anything like that. The problem is that the constructor of my custom textbox is not being called and also the binding is not updated until i change the actual value in my custom control. The datagrid's virtualization is re-using previously created controls.
I do not want to turn off virtualization. Is there a way to specify how my custom control should be recycled (virtualized)? Or perhaps an event that is fire when Controls are virtualized or recycled?
Any help will be much appreciated.