I am using a time picker control. below is my code in xaml page
<xctk:TimePicker Height="23" Width="150" HorizontalAlignment="Left" Grid.Column="3" Name="DtPktDlvryEndDate" Focusable="False" VerticalAlignment="Center" TextAlignment="Left" Format="Custom" FormatString="hh:mm tt" IsEnabled="{Binding Path=ATGTransDetailsModel.IsAtgConfig}" Value="{Binding Path=ATGTransDetailsModel.DlvryEndDateTime, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
and in view model :
public string DlvryEndDateTime
{
get
{
return dlvryEndDateTime;
}
set
{
dlvryEndDateTime = value;
OnPropertyChanged("DlvryEndDateTime");
}
}
Problem is when I use the up or down arrow to change the time,application giving exception like
Index was out of range. Must be non-negative and less than the size of the collection.
Instead of string, i gave datetime for the property in the model, This way also giving same exception.
When I remove Format="Custom" FormatString="hh:mm tt" from xaml, exception is not coming.
Thing is that i need 24hrs format to display the time.
Comments: ** Comment from web user: BoucherS **
Hi,
Based on your code snippet, here;s what I used (property DlvryEndDateTime is a DateTime) :
```
<xctk:TimePicker Height="23"
Width="150"
HorizontalAlignment="Left"
Grid.Column="3"
Name="DtPktDlvryEndDate"
Focusable="False"
VerticalAlignment="Center"
TextAlignment="Left"
Format="Custom"
FormatString="hh:mm tt"
CultureInfo="en-US"
Value="{Binding DlvryEndDateTime, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
```
It worked without any exception.
What is your system language ? Can you send a sample project with the exception if you still have an exception?