Reputation: 1161
I have 2 controls: A DatePicker (for the date) and a TextBox (for the time).
Both are linked to the same property MyDate
.
On startup the date is now and the time is now, but when I update the date the time changes to 0:00
.
Is there a way to only change the date on the property and leave the time alone?
I understand why and how it is happening but how would I solve this by not altering the property?
<DatePicker VerticalContentAlignment="Center" FontSize="12" Text="{Binding Path=MyDate, StringFormat='d', UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
</DatePicker>
<dxe:DateEdit Height="25" MaskUseAsDisplayFormat="True" AllowDefaultButton="False" EditValue="{Binding Path=MyDate}" Mask="HH:mm">
<dxe:DateEdit.StyleSettings>
<dxe:DateEditPickerStyleSettings/>
</dxe:DateEdit.StyleSettings>
</dxe:DateEdit>
Upvotes: 0
Views: 281
Reputation: 169160
The built-in DatePicker control selects only a date without any specific time so I am afraid it makes no sense to try to display the time of the selected date in a TextBox.
You should bind the DatePicker and the TextBox to two different source properties, a DateTime?
and a TimeSpan
respectively.
The other option would be to use another control that selects a date and a time, for example this one: http://wpftoolkit.codeplex.com/wikipage?title=DateTimePicker
Upvotes: 3