2012-04-15 74 views
1

我正在构建一个需要显示并接受来自我的模型(从数据库中检索)的日期的应用程序。该模型揭示了一个名为EntryTime属性:WP7 DatePicker,TimePicker数据绑定

private DateTime entryTime; 

[Column] 
public DateTime EntryTime 
{ 
    get { return entryTime; } 
    set 
    { 
     if (entryTime != value) 
     { 
      this.NotifyPropertyChanging("EntryTime"); 
      entryTime = value; 
      this.NotifyPropertyChanged("EntryTime"); 
     } 
    } 
} 

我都一个datepicker和我的网页上一个TimePicker,并希望他们都绑定到EntryTime。我尝试了通过结合值结合他们,但没有奏效:

<toolkit:DatePicker HorizontalAlignment="Left" Margin="151,6,0,0" x:Name="dateCurrent" VerticalAlignment="Top" Width="175" Value="{Binding CurrentEntry.EntryDate}" /> 
    <toolkit:TimePicker HorizontalAlignment="Left" Margin="313,6,0,0" Name="timeCurrent" VerticalAlignment="Top" Value="{Binding CurrentEntry.EntryDate}" Width="137" /> 

我是比较新的Silverlight的,所以我不知道我能做些什么,以时间选择器只绑定到时间EntryDate和DatePicker作为EntryDate的日期。

谢谢你的帮助

回答

2

该绑定应该工作。如果你能详细说明你遇到了什么问题,那会很好。我注意到你缺少的一件事是你的绑定上的“双向”模式:

<toolkit:DatePicker HorizontalAlignment="Left" 
       Margin="151,6,0,0" 
       x:Name="dateCurrent" 
       VerticalAlignment="Top" 
       Width="175" 
       Value="{Binding CurrentEntry.EntryDate, Mode=TwoWay}" /> 

    <toolkit:TimePicker 
       HorizontalAlignment="Left" 
       Margin="313,6,0,0" 
       Name="timeCurrent" 
       VerticalAlignment="Top" 
       Value="{Binding CurrentEntry.EntryDate, Mode=TwoWay}" Width="137" /> 
3

我有同样的问题。尝试将DatePicker绑定到DateTime?不到日期时间