How to use DateTimePicker binding in wpf
binding, c#, datepicker, wpf, xaml
Solution
try to use http://wpftoolkit.codeplex.com/documentation
Refer to the following namespace
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
and then
<xctk:DateTimePicker x:Name="dtpStartTime"
Format="Custom"
FormatString="HH:mm tt"
Margin="5"/>
Problem
In my wpf application, in CustomView window, following are the properties which I declared, ``` 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"/> ``` In this way, I'm getting Date in my starttime and stoptime controls. But I want time in "hh:mm tt" formats. DateTimePicker control is not available in WPF toolbox. so for getting time in the specified format instead of date, what should I do? Please suggest.