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.
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"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With