Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hello, I have a dateEdit which I want the user to be able to 'Clear' the value. This should set the bound date (ExpiryDate) to be 1/1/1900 but I want the user to see nothing in the field. At the moment they are seeing 1/1/1900.
                                    How do I go about this? I have the following.

                                    <dxe:DateEdit Name="txtExpiryDate" EditValue="{Binding ExpiryDate}" DisplayFormatString="dd MMM yyyy" ShowNullText="True" NullText="" NullValue="1/1/1900" />

                                    Thanks in advance

                                • Hi Phillip,

                                  Thank you for contacting us. I believe that the cause of the issue is that the value you are passing to the NullValue property is considered as a string. That is why, a standard Object.Equals method returns false when NullValue is compared with EditValue. To solve the issue, you need to pass a DateTime value to the NullValue property. To do this, use a converter or assign this value programmatically.

                                  If you need any further assistance with this subject, feel free to reactivate this ticket.

                                  Thanks
                                  Dimitros

                                • Phillip Williams 01.10.2012

                                  Thanks for that,

                                  I have updated my xaml to the following now that works. However when clicking on the field it shows 1/1/1900 (the NullValue). My question is can I suppress showing this at all or set it to empty?

                                                              <dxe:DateEdit Name="txtExpiryDate" EditValue="{Binding ExpiryDate}" DisplayFormatString="dd MMM yyyy" ShowNullText="True" NullText="" >
                                                                  <dxe:DateEdit.NullValue>
                                                                      <sys:DateTime>1/1/1900</sys:DateTime>
                                                                  </dxe:DateEdit.NullValue>
                                                              </dxe:DateEdit>

                                  Thanks again,

                                1 Solution

                                Creation Date Rating Importance Sort by
                                0

                                Hi Phillip,

                                Thank you for the update. I suggest you use a Value Converter for this task in the following manner:

                                [C#]
                                public class Conv : IValueConverter { public DateTime Null { get; set; } public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(Null.Equals(value)) return null; return value; } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { if(value == null) return Null; return value; } }

                                [XAML]
                                <local:Conv x:Key="conv"> <local:Conv.Null> <sys:DateTime>1/1/1900</sys:DateTime> </local:Conv.Null> </local:Conv> <dxe:DateEdit Name="txtExpiryDate" DisplayFormatString="dd MMM yyyy" ShowNullText="True" NullText="" EditValue="{Binding ExpiryDate, Converter={StaticResource conv}}"/>

                                Please try this solution and let me know of your results.

                                Thanks,
                                Alexander

                                • Phillip Williams 01.11.2012

                                  Thanks that worked perfectly.

                                • You are welcome, Phillip!

                                  Thanks,
                                  Alexander

                                • Marc Perna 02.27.2015
                                  Hi,

                                  I'm trying to do it in a similar way. My point  of view is i have a lot of dateedits in my app and all them must work with null in the same way, so following Phillip's problem a way to do it could be create a Style and apply it to your dateedits

                                  <Style x:Key="DateEditOldNullable" TargetType="de:DateEdit">         
                                  <Setter Property="NullValue">             
                                  <Setter.Value>                                 
                                  <sys:DateTime >1/1/1900</sys:DateTime>  <!-- Date in English Format -->
                                  </Setter.Value>         
                                  </Setter>          
                                  <Setter Property="AllowNullInput" Value="True" />          
                                  <Setter Property="ShowNullText" Value="True" />         
                                  <Setter Property="NullText" Value="-No Date-"/>     
                                  </Style>
                                • Thank you for sharing your experience with us, Marc! As an alternative solution, you can set NullValue using a custom MarkupExtension, bind it to a static property, etc.

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2015 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners