We had a requirement to use xammaskededitor inside a xamgrid . For this I added a customcolumn which has a displaycontrol as a textblock and the editor control as the Xammaskededitor control.
For some reason in edit mode , when the user empties the values for eg : no value , which is equivalent to "__/__/__" according to my mask the under lying View model is not getting updated properyly. If i change it a valid value I can see the view model getting updated and the cell gets updated to the new value.But the problem comes when the user wants to have an empty date value, the cell is retaining the old value because the view model newver gets updated in those scenarios?
I followed the apporach here to add the custom column to the grid.
http://blogs.infragistics.com/blogs/devin_rader/archive/2010/07/08/creating-custom-columns-for-xamgrid.aspx
To Reproduce:
1.Create a xamgrid.bind it to a view model
2. Add a customcolumn to the grid which has TextBlock as the displaycontrol and the XamMaskEditor as the editor control.Bind it two way to the view model.
3. When the user empties the text, the view model is not updated and the cell retains the old value.When the value is set to a valid value it behaves properly.
(I also noticed that when the XamEditor is used as regular control on the form it behaves properly)
the lost focus issue is still not solved.when the XamMaskedEditor has an invalid date and if we try to handle the that in the lost focus its not working..
this is the lost focus event in the CustomDateColumnProvider.
e)
{
.Empty;
;
)
.DEFAULT_TXT.Trim()))
dateValue;
dateValue))
((
)sender).Focus();
Got the sample...Our major issue is the inability to use the lost_focus event of XamMaskedEditor inside the grid, which I have mentioned in the post...Basically what I was trying to do is when the data entered by the user is invalid , keep the focus on the XamAmskedEditor field .. In the Lost_focus event of the XamMaskedGrid in the Customcolumn the code was, --DateTime.TryParse(the column value ) ----if its an invalid date time , keep the focus on the currently edited XamMasked field..But this was not working, focus will go away regardless of setting the focus back to the cell in edit mode ..
Hello,
I sent a sample based on your code above to our engineers for review, and they pointed out some things that are problematic. The two main issues here are:
1. The overridden methods in the custom provider class (CustomDateColumnProvider) should use the Binding objects that are already being passed into them, rather than creating your own Bindings.
2. The Column's ValueConverter and EditorValueConverter properties should be set to use your DateConverter (cf. CustomDateColumn constructor).
Please test the attached sample and let me know if this resolves the issues you are having with the custom date column.
Thanks,
Hitting more issues now with the control If the user enters an invalid data value ( Eg: 15/15/11) ...the controls automatically clears off the value and also doesn't highlight the columns ..I have handled lost focus event to check whether the value entered is a valid data and set the focus back...That doesn't seem to be happening ..
If u set it to empty string in the ConvertBack then it doesn't work due to the reason u explained before.
I have to set it to some datetime value to make it work.. Then the view model will have that value...Now we build some logic downs tream saying that if thae view model value is this datevalue ..treat it as null...pain in the neck...