Wednesday, 14 August 2013

Set Selected Date to TimePicker wpf

Set Selected Date to TimePicker wpf

I want Selected Date for my TimePicker. When I select specific date from
calendar which present in my View Window, that date should assign to
Timepicker.
Xaml:
<DataTemplate x:Key="EditableDataTemplate">
<StackPanel Orientation="Horizontal" Width="596">
<xctk:TimePicker Name="StartPicker" Value="{Binding StartValue,
Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type
Window}}}" Format="Custom" FormatString="hh:mm tt" Background="Yellow"
Padding="0" Margin="0" BorderThickness="0" Width="100"
EndTime="11:59:0"/>
<xctk:TimePicker Name="EndPicker" Value="{Binding EndValue,
Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type
Window}}}" Format="Custom" FormatString="hh:mm tt" Background="Yellow"
Padding="0" Margin="0" BorderThickness="0" Width="60"
EndTime="11:59:0"/>
</StackPanel>
</DataTemplate>
Below property updates Time for TimePicker but sets Today's Date. I want
selected Date which I select at runtime.
private DateTime _started_at;
private DateTime _ended_at;
public DateTime StartTime
{
get
{
return _started_at;
}
set
{
_started_at = value;
}
}
public DateTime EndTime
{
get
{
return _ended_at;
}
set
{
_ended_at = value;
}
}
Ideas?

No comments:

Post a Comment