日期选择器更新时间选择器
我有一个带有日期选择器和时间选择器的表单,它们都绑定到模型中的相同属性,
这里是我的简单模型:
private DateTime _end;
[Required]
public DateTime End
{
get
{
return _end;
}
set
{
_end = value;
RaisePropertyChanged(() => End);
}
}
视图模型具有 ModelObject 的属性。
我的 XAML 看起来像这样,
<sdk:DatePicker SelectedDate="{Binding Path=CurrentAppointment.End, Mode=TwoWay}"/>
<toolkit:TimePicker Value="{Binding Path=CurrentAppointment.End, Mode=TwoWay}" />
有一种简单的方法可以在我选择日期时提前更改时间(它总是返回到 00:00,因为日期选择器将日期设置为 2011-04-29 00:00:00)或者做当我想将其放入数据库时,我必须在模型中为时间创建一个属性,并将日期和时间放在一起?
I have a form with a datepicker and a timepicker which both are bound to the same property from the model
here my simple Model:
private DateTime _end;
[Required]
public DateTime End
{
get
{
return _end;
}
set
{
_end = value;
RaisePropertyChanged(() => End);
}
}
the viewmodel has a property of the ModelObject.
My XAML looks like this
<sdk:DatePicker SelectedDate="{Binding Path=CurrentAppointment.End, Mode=TwoWay}"/>
<toolkit:TimePicker Value="{Binding Path=CurrentAppointment.End, Mode=TwoWay}" />
is there a simple way to precent the time from changing when i pick the date (it always goes back to 00:00 because the datepicker sets the date to 2011-04-29 00:00:00) or do i have to make a property for the time in my model and put the date and the time together when i want to put it in my database?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
完全相同
这个问题与一起使用 silverlight datepicker 和 timepicker
使用转换器
This question is exactly the same as
Using silverlight datepicker and timepicker together
Use Converter
您可以决定不使用数据绑定并通过事件实现逻辑,也可以使用转换器并将其参数绑定到
TimePicker
。当您更改日期时,您可以解析参数并将其附加到日期时间。You could either decide not to use data-binding and implement your logic with events, or you could use a converter and bind its parameter to the
TimePicker
. When you change the date, you can parse the parameter and attach it to the datetime.