Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
485
TimeSpan and XamMaskedEditor
posted

Hi,

I want to display a TimeSpan value in a XamMaskedEditor. I have the following XAML:

<igEditors:XamMaskedEditor ValueType="{x:Type System:TimeSpan}" Mask="##:##" Value="{Binding Path=MyTimeSpanValue}">
    <igEditors:XamMaskedEditor.ValueToTextConverter>
        <local:TimeSpanToTextConverter />
    </igEditors:XamMaskedEditor.ValueToTextConverter>
   
<igEditors:XamMaskedEditor.ValueToDisplayTextConverter>
       
<local:TimeSpanToTextConverter />
   
</igEditors:XamMaskedEditor.ValueToDisplayTextConverter>
</igEditors:XamMaskedEditor>

My Convert method looks like this:

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
   
if (value is TimeSpan == false)
        return Binding.DoNothing;

    TimeSpan ts = (TimeSpan)value;
   
string result = ts.Hours.ToString().PadLeft(2, '0') + ":" + ts.Minutes.ToString().PadLeft(2, '0');
   
return result;
}

Whenever Convert is called, the result is as expected. 
The result for a TimeSpan object with Hours set to 1 and minutes set to 5 will be "01:05"

Still, this is not working in the XamMaskedEditor -- it will just display the literal : from the mask.

I'm probably missing something..