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 trying to style the DropDownDatePicker control so that when it drops down you can select a date AND enter a time. I figured I could use Blend to do this. I simply created a window with a DropDownDatePicker control on it. I then ran my app and everything worked (wanted to make sure it wasn't a .licx issue or something). In Blend I then rightclicked on the control and "edit control part template" and "edit a copy." This makes a copy of the control template in the resources section of my window. As soon as I do this I get an exception in Blend that says "The element type 'Mindscape.WpfElements.DateTimeReadOnlyDisplayElement' does not have an associated TypeConverter to parse the string 'Mindscape.WpfElements.DateTimeReadOnlyDisplayElement'. Here is the XAML that was generated by this action in Blend: <Window x:Class="Window1" Any thoughts? Also any general thoughts or pointers on creating a control that will let me pick the date AND the time...this is an important part of our application. Thanks, Sean |
|
|
Unfortunately the Blend error appears to be a Blend bug. We're not doing anything unusual or immoral in our default control templates so we believe this must be some kind of limitation in Blend. Exception aside, the extracted template looks mostly okay, except that it has pulled out the DateTimePicker.DisplayElements collection. This would normally be generated indirectly based on the date-time format rather than hardwired into the template. If you email me on ivan @ the obvious domain name I'd be happy to send you a copy of the default template (or, if you have Enterprise Edition, you can copy it out of Themes\Generic.xaml). However, I think some care will be required to create a control that will let you pick the date and time. The problem is that the MonthCalendar control only returns a date: it discards the time part of the DateTime. So it will be a bit tricky to use a MonthCalendar as part of your control (and because a DateTime is immutable we can't use a MonthCalendar to edit the "date" part and numeric boxes to edit the "time" part, we need a control that will return a DateTime entire). My suggestion would therefore be, rather than creating a custom template for the DropDownDatePicker, would be to template the DateTimePicker, or to use a DropDownEditBox with a retemplated DateTimePicker in its drop-down area. The control template would go something like this: * Basic layout: a Grid, say with three rows * Top row: ComboBox for the month and spinnable IntegerTextBox for the year. To see how to bind these up, refer to the Elements sample, DateTimePickerStyling.xaml. * Middle row: ListBox containing the values 1 to 31, with the ItemsPanelTemplate being a UniformGrid with 7 columns so as to get the calendar-like layout. A bit of ingenuity may be required to align these to the weekdays (you may need to write code; if you have Enterprise Edition you can probably reuse some of the code from MonthCalendar). Bound to the day -- again see DateTimePickerStyling.xaml. * Bottom row: spinnable IntegerTextBoxes, bound to the hour and minute. Binding to time elements is not shown in DateTimePickerStyling.xaml but it will work in the same way -- you just need to have a format on the DateTimePicker that includes these elements, and pick them out positionally from the DisplayElements collection. I realise this may sound a bit intimidating but we'd be very happy to work with you on this if required, as we realise it would make a useful sample or enhancement for a future version. |
|
|
Ivan, I will definitely take a look at this after my deadline, for now I'm under some tight time constraints. I think I can work with the DropdownDatePicker as it is if I can set the format to Custom and use MM/dd/yyyy hh:mm:ss tt as my format provider. This way the user can simply change the day on the calendar and the time on the face of the control. This almost works but I think I may have found a bug for the way I'm using it. I am using the DropdownDatePicker in a property grid as the editor for my date time values. All works fine except that if a section of the date is double zeros ("00") then the "00" doesn't appear, instead it is left blank. I have attached a simple sample that demonstrates exactly what I am doing. Any advice would be appreciated. Thanks again for your assistance! Sean |
|
|
I may be being dumb here but when I fire up your sample I see the zeroes displayed -- no blanks. If I drop down the date, or edit a time element to be 0, it still displays okay. (I have tried changing your sample to use the CustomFormat you describe, but that doesn't make any difference. Also, by "a section of the date" I assume you mean a section of the date-time as a whole, because the date elements aren't allowed to be 0, only the time elements.) Are there any specific steps I need to take to reproduce the bug? If not, this may be a versioning thing -- can you let me know which version of .NET you have installed (3.0, 3.5 or 3.5 SP1) and whether you are using a recent nightly build of WPF Elements? Thanks! |
|
|
Ivan, I'm using 3.5SP1, but I'm not using the nightly builds, just the most recent "release" build. By "date" I actually meant "time" (sorry about that, been on weeks of coding marathon's). In the sample I posted I'm seeing 1:__:__ AM (note not actually seeing underscores, that is where the "blank values are"). I can take a screenshot and post it in the morning when I get back to the office. Thanks, Sean |
|
|
Would it be possible for you to download and try the current nightly build and see if it addresses your problem? There have been a number of bug fixes and enhancements since the last "release" build -- including one which addressed zeroes appearing as blanks when initially set in an IntegerTextBox (which is what the DateTimePicker uses internally), which sounds exactly like what you're seeing. (By all means switch back to RTM after doing this test, especially you still see the bug! Just want to determine whether this is an environmental difference or something we have already fixed. However our nightly builds are fully supported, and they are generally very stable.) |
|
|
I'll do it first thing in the morning (Atlantic Time so about 11 hours from now).
Sean |
|
|
Updating to the latest nightly build of the WPF Elements (3/25/2009) fixed the problem. Thanks! Sean |
|
|
Actually it only partially fixes the issue. A time should always read 1:00:00. With this build I get 1:_0:_0 where the leading 0 is missing (again, underscores not actually displayed, just representing the missing characters). For it to truly look "right" as a time it should have double 00's. I've attached a screenshot in case you can't duplicate. Sean |
|
|
Thanks. This was a bug where zero-padding wasn't being applied until the value had first changed away from the default (0). I've committed a candidate fix. This will be in the next nightly build, available from the store after about 1430 GMT, or given that you're under time pressure we'd be happy to push it up immediately for you to test. |
|
|
Ivan, I've just downloaded the latest nightly build file WpfElementsTrial-20090326.msi. I am not seeing any difference in my test appication above (or my production application). Also, for some reason the WPFElements .dll in that package is dated 3/9/2009...may be relevant. Doubt that I'm doing anything wrong..I've confirmed that my references are to the new .dll that got installed as part of the updated MSI. Thanks, Sean |
|
|
Something seems to have gone wrong with the automatic upload of nightlies last night -- the build you need will be labelled 27 Mar 2009. I'll ping our Web guy and get this uploaded for you now. |
|
|
Okay, the 27 Mar 2009 build is now available -- please give this a go and let us know if you still see the problem. Sorry for the hiccup. |
|
|
Great, that did the trick! Sean |
|