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
545
Formatting preview of DateTime field with XamComboEditor
posted

I have a data grid with a field that is bound to a DateTime. Since the user only can choose from a predefined set of dates, I use a XamComboEditor to edit the field. I want to specify formatting for the dates and I have successfully been able to do so for the drop down. However, I'm not able to set the date format of the "preview" of the field (i.e. when the field is not in edit mode).

How do I set the date format of the "preview"?

The XAML for the field:

---------------------

<igWPF:Field Name="ReferenceDate" Label="Reference date">

    <igWPF:Field.Settings>
<igWPF:FieldSettings EditorType="{x:Type igWPF:XamComboEditor}">
   <igWPF:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igWPF:XamComboEditor}">
   <Setter Property="ComboBoxStyle">
<Setter.Value>
   <Style TargetType="ComboBox">
<Setter Property="ItemTemplate">
   <Setter.Value>
<DataTemplate>
   <!-- Works just fine, but only in edit-mode -->
   <TextBlock Text="{Binding Converter={StaticResource dateTimeConverter}}" />
</DataTemplate>
   </Setter.Value>
</Setter>
<Setter Property="SelectedItem" Value="{Binding DataItem.ReferenceDate}" />
   </Style>
</Setter.Value>
   </Setter>
   <Setter Property="ItemsSource" Value="{Binding DataItem.AvailableReferenceDates}"/>
   <Setter Property="DropDownResizeMode" Value="None"/>
   <Setter Property="IsReadOnly" Value="{Binding DataItem.HasVariance, Converter={StaticResource invertBooleanConverter}}" />
   <!-- Does not seem to work -->
   <Setter Property="Format" Value="{x:Static ValueConverters:DateTimeLongFormatConverter.DateFormat}" />
</Style>
   </igWPF:FieldSettings.EditorStyle>
</igWPF:FieldSettings>
    </igWPF:Field.Settings>
</igWPF:Field>

PS! I would love to see better code-formatting support in your forum editor...

  • 138253
    Offline posted

    Hello Atle,

     

    I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.

  • 138253
    Offline posted

    Hello Atle,

     

    Thank you for your post. I have been looking into it, but I wasn’t able to reproduce your behavior. I used the following Format “dd-MMM” and it works as expected. Could you please try to set the format like this and see if it works for you. If it does the issue comes from the static value you use, if it still doesn’t work, could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.

     

    Looking forward for your reply.