In my wpf application in the CustomView window, the following properties that I declared are
private DateTime starttime { get { return DateTime.Parse(StartTimeText.Text); } set { StartTimeText.Text = value.ToString(); OnPropertyChanged("starttime"); } } private DateTime stoptime { get { return DateTime.Parse(StopTimeText.Text); } set { StopTimeText.Text = value.ToString(); OnPropertyChanged("stoptime"); } } protected virtual void OnPropertyChanged(String time) { if (System.String.IsNullOrEmpty(time)) { return; } if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(time)); } } public event PropertyChangedEventHandler PropertyChanged;
In xaml,
<DatePicker x:Name="StartTimeText" SelectedDate="{Binding Path=starttime}" BorderThickness="0" Background="Yellow" Width="100"/> <DatePicker x:Name="StopTimeText" SelectedDate="{Binding Path=stoptime, Mode=TwoWay}" BorderThickness="0" Background="Yellow" Width="60"/>
This way I get Date during my startup and time control. But I want time in "hh: mm tt" formats. The DateTimePicker control is not available in the WPF toolbar. so to get the time in the specified format instead of the date, what should I do? Please suggest.
source share