Hi, I am using a textbox in a field of the XamDataGrid to display a numeric value, that has prefix and suffix. On lostfocus of the textbox, I validate user changes for invalid entry and display the message to user. But after showing the message I must return the focus to the textbox in the particular cell, which does not happen. Even though I set the txtboxname.focus(), it goes on a infinite loop.
Could you please help me how to do this? Thanks in advance.
Regards,Balaji RajendranCCH - WK, Torrance
Hello Balaji,
This is because you are using a custom template for the cell value presenter (which I am assuming because you are using a text box). The XamDataGrid uses PART names elements in its template. As you have modified the template, the XamDataGrid is not aware of which element it should focus - enter edit mode and focus it. There are couple of ways to go around that -
1. You can use our editors with masks and value constraints. You will also get all of the cell events working.
2. You can use the hosting controls approach in this blog post by Andrew Smith, which will also give you the same result : http://blogs.infragistics.com/blogs/andrew_smith/archive/2009/03/27/hosting-wpf-controls-in-a-xamdatagrid-cell.aspx