DatePicker formats incorrectly when used in a ElementHost

May 21, 2009 at 9:19 PM
Edited May 22, 2009 at 2:42 PM

I have a Window Form that includes a ElementHost as the same size as the DatePicker that I have specified as its child. (109x24)

The problem is that although the DatePicker looks fine while in the studio, when actually run the text box width is about 24px with a approximate 40px space followed by the calendar button (which is now positioned about 3 or 4px lower than in the studio) and the remainder of the Elementhost is again blank?  What gives?

Check out this image of what I am talking about - Click here

I have tried messing with the min/max Height/Width as well as setting the actual size and nothing seems to matter.  Again its perfect in the studio - just not sure why its so messed up when running the application.   Has anyone seen anything like this or have any suggestions on how I can force the position of the textbox and icon to where they should be?

Also, why is that the width and height settings do nothing in the case where its a child to ElementHost?   I suspect its completely related to the use of a ElementHost as I use the same control in other WPF application and it works great.

         private Microsoft.Windows.Controls.DatePicker dateTimePicker_DateOfBirth;
         this.dateTimePicker_DateOfBirth = new Microsoft.Windows.Controls.DatePicker();

         // elementDatePicker
         this.elementDatePicker.BackColor = System.Drawing.SystemColors.Window;
         this.elementDatePicker.ForeColor = System.Drawing.SystemColors.WindowText;
         resources.ApplyResources(this.elementDatePicker, "elementDatePicker");
         this.elementDatePicker.MinimumSize = new System.Drawing.Size(109, 0);
         this.elementDatePicker.Name = "elementDatePicker";
         this.elementDatePicker.Child = this.dateTimePicker_DateOfBirth;

Please help!



May 22, 2009 at 8:32 PM

Unfortunately the DatePicker doesn't support this, however it is on our list of customer scenarios.