How to change TimePicker format using properties
c#, timepicker, wpf
Solution
Use the `FormatString` property to format your display. I think you have the formats covered in your previous questions. You should also set `Format` to `Custom`.
Here's a suggestion:
<xctk:TimePicker Format="Custom" FormatString="hh:mm:ss tt" />
You should note that using `HH` for hours gives you 24-hour format, while `hh` will give you a 12-hour format.
You can check the documentations here.
Problem
I've used TimePicker format in my wpf application using extended wpf toolkit. I'm using "HH:MM" format. but problem is, the button which allows to select hours directly from the options, showing 24 hours format, but I want 12 hours only. But I managed that through properties of TimePicker by changing Endtime from "23:59" to "11:59". But those up and down buttons still showing hours upto 23. so, If I want to make upto 11, what should I do? Can I achieve this by TimePicker's property only? also It's not showing part of day i.e AM/PM. I also want another button which should show me these two options (i.e AM and PM). Please suggest, how should I proceed? My Timepicker controls which are bound to DateTime object in my code behind are as follows, ``` <Window x:Class="TimeSheet.CustomView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" x:Name="Time" Title="CustomView" Width="596" Height="596"> <Grid> <StackPanel Orientation="Horizontal" Height="30" Width="596" Margin="0,137,-8,399"> <xctk:TimePicker x:Name="StartTimeText" Value="{Binding starttime, ElementName=Time, Mode=TwoWay}" BorderThickness="0" Background="Yellow" Width="113" EndTime="11:59:0" AllowSpin="False"/> <xctk:TimePicker x:Name="StopTimeText" Value="{Binding stoptime, ElementName=Time, Mode=TwoWay}" BorderThickness="0" Background="Yellow" Width="115" EndTime="11:59:0" AllowSpin="False"/> </StackPanel> </Grid> </Window> ``` UI of my Window-