开发者

Get only the Date from the WPF DatePicker

开发者 https://www.devze.com 2023-01-12 19:44 出处:网络
when I bind the wpf datepicker SelectedDate I get this 2010-08-25 08:15:33. As I do a comparison: if (SelectedStart >= SelectedEnd)

when I bind the wpf datepicker SelectedDate I get this 2010-08-25 08:15:33.

As I do a comparison:

if (SelectedStart >= SelectedEnd)
     return false;
else
    return true;

I get always true. I have to compare the D开发者_运维技巧ATE without the TIME. But I do not want to convert to a string and parse this then as a Date. That would be silly.

Hm the control is called DATEpicker not DATETIMEpicker seems MS did naming mistake ;P

I already tried this: SelectedDate="{Binding Path=SelectedStart, StringFormat=\{0:d\}}"

But I always get the full DateTIME.


if (SelectedStartDate.Date >= SelectedEndDate.Date)

This will compare only the date part of the DateTime

0

精彩评论

暂无评论...
验证码 换一张
取 消