0

i am using TimePicker control for the first time. I want to get the selected time into my ViewModel as well as bind the sele.cted time into a textblock/textbox. I am Able to bind the TextBox to selected to selected value But it displays Date As well with time. I want to display only time meaning, get only time from TimePicker.

the textbox data looks like- 2/8/2015 10:18:35 PM What want to display is - 10:18:35 PM

I dont understand why TimePicker should display date?? If so i could go for DateTimePicker control. But now i need only time to be selected and displayed. Here is my code trying to get it.. Please help me with this......!

Here is my code trying to get it..

    Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
    <vm:Data></vm:Data>
</Window.DataContext>
<Grid>
    <TimePick:TimePicker Name="tp" Format="LongTime"  FormatString="hh:mm tt" Margin="10,52,174,244"/>
    <TextBox Text="{Binding Path=Value, ElementName=tp}"  Margin="0,127,174,153"></TextBox>
</Grid>

Kulasangar
  • 9,046
  • 5
  • 51
  • 82
vishwas 115
  • 23
  • 1
  • 5

1 Answers1

0

Are you sure that you're only using the TimePicker control? If so i guess it should only display the time. If you're using the DateTimePicker control then you have to split in order to display only the date or the time:

Datepicker returning only date

Reference

Did you try out other TimePicker controls out there?

What is currently the best, free time picker for WPF?

Community
  • 1
  • 1
Kulasangar
  • 9,046
  • 5
  • 51
  • 82
  • Hello..! Yes I am Using TimePicker Control which is the extended wpf toolkit. – vishwas 115 Feb 09 '15 at 06:03
  • But when I bind its value to a textbox it displays time but date also with it..! As I change the time through dropdown, its updating fine. But its having date also with it..! So please provide a suggestion/solution. Thank you in advance. – vishwas 115 Feb 09 '15 at 06:04
  • Try adding the `Format String` within your `TextBox`: – Kulasangar Feb 09 '15 at 06:11
  • No..! It has No effects..!! with this string format, its Not even updating now.! Tried altering it too..!! – vishwas 115 Feb 09 '15 at 06:37