This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I'm using the DropDownDatePicker and TimePicker controls in the DataTemplate for a DateTime PropertyEditor. (They in two cells of a grid and both reference the same DateTime property but the TimePicker uses a DateTimeToTimeOfDayConverter.) That works reasonably well. In the DropDownDatePicker, I notice that users can type only numbers in the year and day fields (and in the correct range for the given month, thank you!) , but they can type pretty much anything into the Month field (and all fields in the TimePicker). Since the invalid value cannot be parsed into a DateTime, an exception is thrown with every invalid character entered. I'd like to avoid this by providing a template for the DropDownDatePicker (actually the DateTimePicker control used as the display for the DropDownDatePicker) that uses a set of dropdown ComboBoxes containing the appropriate values for the various fields. Do you have sample code that shows how to accomplish that? BillBR |
|
|
Hello BillBR I have resolved the exception of typing an incorrect month name. This will be resolved in the next nightly build. I wasn't able to reproduce any similar exceptions in the TimePicker. Let me know if there are any issues with the TimePicker. There isn't a code sample demonstrating the customizations you mentioned, but I can walk you through the general idea. Go to the install directory and go to the Themes folder. This contains all the theme source code for all controls which is freely available no matter what license you have. Look for the file for your favourite theme for the date time controls, e.g. Alloy.DateTimeControls.xaml. Open this up and you'll find the styles for the DateTimePicker at the top (it's less than 100 lines of code). Here you will see this control displays a list of different components. There are 3 types of components: numeric (used for year and day etc), selectable (for months) and readonly (for string literals such as slash or colon). As you can see the selectable components are already styled as a ComboBox. But they are editable meaning they can accept any user input and they don't display the drop down button. In your custom style you could make this a readonly combo box. The numeric component displays an IntegerTextBox, but you could change this to being a combo box if you want. You'd need to create a converter that takes the minimum and maximum values to generate the items source of the combo box. These components are then used by the DateTimePartTemplateSelector which is used by the DateTimePicker style. If you create a DateTimePicker style in a resource dictionary with no x:key, then it should be automatically used as the DateTimePicker style all throughout your application including nested within DropDownDatePicker controls. Let me know if you need any assistance with this. Jason Fauchelle |
|
|
Thanks for making the change to deal with the exception when users input invalid month names, Jason. I'll have a look at this tomorrow when I download the next nightly build. Thanks also for the direction on modifying the templates. That's very helpful. |
|
|
The update to handle the exceptions when a user enters invalid information works great with the nightly build of 08/29/13! It may be some time before I get to creating a new template with dropdowns etc. I'll let you know when I do. BillBR |
|