Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Unassigned: Wpf TimePicker gives exception when uses up and down arrow marks [22039]

$
0
0
Hi,

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?


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>