我正在使用c#、wpf和xceed工具包来获取更高级的项目,但现在我正在努力从选择器中获取值。
下面是我在xaml中所做的:
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
<xctk:DateTimePicker x:Name="fromDTP"/>下面是我在代码隐藏中尝试做的事情,以获取日期:
var datefrom = fromDTP.SelectedDate;但我认为这不起作用,因为它向我显示,当我选择日期时,值仍然是null...even。我是不是漏掉了什么?
发布于 2017-08-10 20:49:21
SelectedDate属性属于WPF DatePicker。而不是xceed项目。你应该使用Value,你可以绑定它。请参见下面的示例。
<xctk:DateTimePicker Format="Custom" x:Name="fromDTP"
FormatString="MM-dd-yy hh:mm:ss tt"
TimeFormat="Custom"
TimeFormatString="hh:mm:ss tt"
Grid.Row="0" VerticalAlignment="Top"
Value="{Binding Path=CleanLogsDeletionDate, Mode=TwoWay}" Height="30" Width="172" />和属性更改的类:
public class HelperInfo : INotifyPropertyChanged
{
private DateTime m_CleanLogsDeletionDate;
public DateTime CleanLogsDeletionDate
{
get
{
return m_CleanLogsDeletionDate;
}
set
{
if (m_CleanLogsDeletionDate != value)
{
m_CleanLogsDeletionDate = value;
OnPropertyChanged();
}
}
}
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}}
https://stackoverflow.com/questions/39505421
复制相似问题