Coded ui Test Unable to find a DateTime picker in an Hierarchy - c#

I’ve 3 Date Time Pickers in a form. I want to select the 2nd Date Time Picker but on playback it always selects the 1st Date Time picker in the hierarchy. I’ve tried giving all the search properties but no success.
Is there a work around for this?

Related

How to set Format for DateTimePicker in WPF

In my application I'm using the DateTimePicker control from the Xceed Wpf toolkit.
I would like to set the format so that only the hours and minutes can be edited, I want to remove the calendar. since I'm using DateTimePicker to establish how long a process takes. Like this 3d print, it took 20h 40m and save it in my database.
enter image description here only this part
To set the format of the Xceed DateTimePicker control to only show hours and minutes, you can set the Format property to "HH:mm". This will display the time in hours and minutes, and only the time portion can be edited.
Example:
<xctk:DateTimePicker Format="HH:mm" />
This will format the control to only show and allow editing of the hour and minute values.

Xaml DatePicker default and earliest date available for selection settings in C#

I have couple of datepicker implemented in Xaml .
- After user picks certain dates, a simple logic finds the earliest of the two dates. Also, it is not necessary for user to pick both dates.
I noticed that the "default" datepicker value if user does not pick any date is 1/1/0001.
Assuming the user picks the second date as 1/1/2017, the earliest of the two dates would always be 1/1/0001 which is not desired. In such scenario, the minimum date should be 1/1/2017.
what is the logic to neglect default date of 1/1/0001
There is a property MinYear which can be set to minimum year accepted which in your case obviously should be 2017. This will solve the problem by automatically limiting range of available values to be lower bounded by 2017-01-01 - this for UWP DatePicker.
In WPF DatePicker there is a DisplayDateStart property which can be set to minimum date available in drop down calendar which can be chosen by user. Similar property DisplayDateEnd is used for setting highest date which can be displayed in DatePicker. DatePicker.SelectedDateChanged is a very useful event which when wired up will capture changes to the dates on all instances of DatePickers and this can be used to create relations between them i.e. to enforce selection of the valid period which starts from date selected on DatePicker 1 and ends on date selected in DatePicker 2 by setting DisplayDateStart on picker 2 to date selected on picker 1 in event handler. This all together provides very high level of flexibility in controlling user input via DatePicker class.

change the color of a specific date on date picker control for specified dates C# Winforms

I am working on a C#/WinForm Application. The user when he activates the datepicker would like to see at a glance up and coming holidays by having the timepicker show them in red.
I have been playing around with the datetimepicker class events and properties below is an example of what I came up with:
DateTime decemberholiday = new DateTime(2013,12,25);
dateTimePicker1.Value = decemberholiday;
if (dateTimePicker1.Value == decemberholiday) {
dateTimePicker1.CalendarForeColor = Color.Red;
I know it is setting the date to the specific date instead of displaying the actual date but this was something i came up with for quick testing purposes. When I run the program - nothing changes. Any input would be appreciated.

DateTimePicker - Which subfield has focus?

I have a class that derives from DateTimePicker. The picker control has format set to DateTimePickerFormat.Custom and custom format string set to yyyy.MM.dd HH:mm in order to display dates in the format 2013.01.25 21:45. Here, 2013 is the year subfield that gets highlited when the users clicks on it with the mouse cursor or tabs to it using the TAB key. Once highlited, the user can use UP/DOWN keys to increment / decrement the year, or manually enter a new year value. The same holds true for the month, day, hour and minute subfields.
For my application, certain dates or time values are forbidden. For instance, consider the following rule:
An appointment can only be scheduled at a time rounded to the nearest 10 minutes. For instance, you can schedule one at either 21:10 or 21:20, not at 21:13.
For this, I need to know which subfield currently has focus. The problem is I don't know how to determine this. If I know which subfield has focus, I could devise the following set of rules in code.
If the minute subfield is selected, and the user presses the UP key, increment the time by 10 minutes.
If the minute subfield is selected, and the user presses the DOWN key, decrement the time by 10 minutes.
If the minute subfield has lost focus, round the minutes up or down to the nearest 10 minutes.
The only problem that remains.. HOW DO I FIND WHICH SUBFIELD CURRENTLY HAS FOCUS?
NOTE: Yes I can make validation checks in OnLeave event but the my application requires that invalid datetime values be skipped altogether. Also, I have checked out the solution given here. But I am inclined to find the active subfield as an exercise as well. Finally, if its of any use, I'm using C# 4.0 on Windows 7 x86.

Configuring the Date Popup on the WPF DatePicker Control

I have a date picker control that I use for a data collection application. It is using MvvM data binding. When going through a list of dates (see fig1) it will populate the date picker correctly. Whenever I hit new, the date pickers are nulled out. When I pull up the popup, it selects the month and year from the previous date that was set to. (fig 2) Is there anyway to default the pop up show the current month in the current year?
Note : I would like to keep the selected date to null on a new entry to force some validation.
Fig 1
Fig 2
The following image is to show what happens when I set the DisplayDateStart.
(original answer was horribly wrong, sorry about that)
Okay, lets try this again.
Have you tried setting the fallback to today's date?
SelectedDate="{Binding TehDate, FallbackValue={x:Static sys:DateTime.Now}}"

Categories