For instance if the value from my database is 04/01/1997 then my xamEditor shows 04/0001
If I change the mask to yyyy/mm then it shows 0004/01
However, if I change my Property (shown below) to a type of string and convert the text manually by building a string from the date it works correctly. Can someone explain why this isn't working?
Here is what my XAML looks like
<igEditors:XamDateTimeEditor Mask="mm/yyyy" Text="{Binding Path=member.init_dt, UpdateSourceTrigger=LostFocus, ValidatesOnDataErrors=True}" >
Here is what my Code Behind looks like
Public Property init_dt As Nullable(Of Date)
Get
If currentRecord Is Nothing Then
Return Nothing
Else
If IsDBNull(currentRecord("init_dt")) = False Then
Dim odte As Date = currentRecord("init_dt")
Return odte
End If
End Get
Set(ByVal x As Nullable(Of Date))
Dim dte As Object
If x IsNot Nothing Then
dte = x
dte = DBNull.Value
If Not currentRecord Is Nothing Then
currentRecord("init_dt") = dte
End Set
End Property
The xamMaskedEditor (xamDateTimeEditor is a derived one) does not currently support a date mask that does not contain a day section. You may submit a feature request here.
Actually I'm mistaken. It didn't used to accept such a mask but in looking into it further it was updated to support it a while back. What version of the control are you using?
2011.1 is the version. Sorry it took so long to reply I was out sick.
I just noticed that you are binding the Text property which is of type string. Can you try binding the Value property?
Should all of my bindings be on value instead of text for xam editors? (When I want to edit the text's value?)
In general you normally want to bind the Value property of the Editor to your actual property. When you bind the Text property all the control gets is a string value and then it has to try and interpret that as the type it is to be editing - in this case a datetime. The way that the xamMaskedEditor works is that when the Text is set it tries to apply that text to the mask characters. That is why when you reversed the mask the 4 and 1 were still applied to the first and second sections respectively. So if you bind to the Value property the control has more information (in this case it has the entire date) and can use that information accordingly (e.g. get the month from it and use that in the month section, etc.).
Thank you very much for your time and explanation. I was just not accustomed to a value property on a textbox. This makes much more sense.