xceedsoftware / wpftoolkit

All the controls missing in WPF. Over 1 million downloads.
Other
3.89k stars 877 forks source link

DateTimePicker seems broken on new build #1034

Open xceedsoftware opened 7 years ago

xceedsoftware commented 7 years ago

EstebanMartinez[CodePlex]
Hello.

I just wanted to report an issue that I encountered today when I updated my nuget packet to the new build.

I have an application that I've had developed for quite a while that used the DateTimePicker as part of search criteria in an MVVM light viewmodel. It worked fine until I updated the package.

I downloaded and referenced the 2.8 libraries and things worked again. So, i'm unsure if something changed that perhaps I am violating, or there may be an issue.

For reference, in my viewmodel I have a property defined as below: private DateTime? _createdAfter = null; public DateTime? CreatedAfter { get { if (IsInDesignMode) { return new DateTime(2012, 12, 12); } else { return _createdAfter; } } set { if (_createdAfter != value) { _createdAfter = value; RaisePropertyChanged(() =gt CreatedAfter); } } } Bound to the DateTimePicker as thus:

ltxctk:DateTimePicker Format=quotCustomquot Value=quot{Binding CreatedAfter, Mode=TwoWay}quot /gt After updating I got the following error:

Index was out of range. Must be non-negative and less than the size of the collection.

with this stack trace error:

at System.ThrowHelper.ThrowArgumentOutOfRangeException() at Xceed.Wpf.Toolkit.DateTimeUpDown.OnValueChanged(Nullable1 oldValue, Nullable1 newValue) at Xceed.Wpf.Toolkit.DateTimePicker.OnValueChanged(Nullable1 oldValue, Nullable1 newValue) at Xceed.Wpf.Toolkit.Primitives.UpDownBase`1.OnValueChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntryamp newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) at System.Windows.DependencyObject.ClearValueCommon(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata) at System.Windows.DependencyObject.ClearValue(DependencyProperty dp)

xceedsoftware commented 7 years ago

BoucherS[CodePlex]
In v3.2, the throw will also manage this case.

xceedsoftware commented 7 years ago

SplinterBaryon[CodePlex]
This error also happens when both the Value and the FormatString is databound like so:

xctk:DateTimePicker Value={Binding StartTime} Format=Custom FormatString={Binding StartFormatString} /

xceedsoftware commented 7 years ago

BoucherS[CodePlex]
In v3.2, the DateTimePicker will throw if the FormatString property is null when Format property is set to Custom.

xceedsoftware commented 7 years ago

BoucherS[CodePlex]
Hi,

Thanks for your feedback.

Make sure that when you use the DateTimePicker.Format property to Custom, you also set a value for property DateTimePicker.FormatString.

Dimigergo commented 6 years ago

Hello!

I use Toolkit latest 3.3 version and the problem still when the FormatString property is bound: <xctk:DateTimePicker Value="{Binding FilterFromDate}" FormatString="{Binding formatFilterDateTime, Source={StaticResource CultureResource}}" Format="Custom"/>

If I use hard coded string format, it works. <xctk:DateTimePicker Value="{Binding FilterFromDate}" FormatString="yyyy.MM.dd HH:mm" Format="Custom"/>

Thanks!

movingcity commented 5 years ago

I use the latest 3.4 version and face the same problem. FormatString have to be hard coded.

XceedBoucherS commented 5 years ago

Hi, This code seems to work: ` <local:CultureResource x:Key="CultureResource" formatFilterDateTime="yyyy.MM.dd HH:mm"/> </Window.Resources>

` ` public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); this.DataContext = this; this.FilterFromDate = DateTime.Now; } public DateTime FilterFromDate { get; set; } } public class CultureResource { public string formatFilterDateTime { get; set; } }`