2016-09-15 5 views
0

私はC#、wpf、xceedツールキットを使用して、より高度な項目 を取得していますが、現在はピッカーから値を取得するのに苦労しています。ここでC#xceed DateTimePicker

は私のXAMLでやったことです:

xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" 
<xctk:DateTimePicker x:Name="fromDTP"/> 

そして、ここでは、私は日付を取得するには、コードビハインドでやろうものです:

var datefrom = fromDTP.SelectedDate; 

しかし、私は、これは」doesnのだと思います値が であることがわかっているので、私は日付を選択しても作業していません。何か不足していますか?

+0

あなたがエクシードツールキットのどのバージョンを使用していますか?コミュニティバージョン2.9.0には 'SelectedDate'プロパティはありませんが、null可能な' DateTime'([docs](https://wpftoolkit.codeplex.com/wikipage?title=DateTimePicker))を返す 'Value'プロパティを持っています。 – Sam

答えて

0

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 

} 

}

関連する問題