질문 DatePicker control displays without a border

  • 06 Maret 2012 10:15
     
     

    I'm trying to create a Silverlight custom control for DateTime that will store dates in UTC time, but display them in local time.

    I've built the control, and it does work, however when I put it in Lightswitch, the DatePicker control displays without a border, and without the calendar icon.  When the control gets focus, the DatePicker border appears, but still no calendar icon.

    I see someone had a similar problem here: http://social.msdn.microsoft.com/Forums/en-US/lightswitch/thread/77093403-3b9d-4ded-be96-1e953075879a and were advised to use DateTimePickerVisual from the Lightswitch Framework.  If I could use Lightswitch's own control, that would be great, but I can't seem to be able to reference it in XAML.  I've tried adding all the Microsoft.Lightswitch.* namespaces I can in an xmlns: tag, but can't find the DateTimePicker control within them.

    Any ideas how I can find this control, or work around the issue with Silverlight's own DatePicker?

Semua Balasan

  • 07 Maret 2012 12:02
     
     
    Bump.  Does anyone know how to reference Lightswitch's own controls from XAML, or how I would do this within a Lightswitch extension?
  • 07 Maret 2012 14:22
     
      Memiliki Kode

    Okay, to access Lightswitch's own controls from Silverlight, add a reference to Microsoft.Lightswitch.Client.Internal

    Then, in you XAML add:

    xmlns:ls="clr-namespace:Microsoft.LightSwitch.Presentation.Implementation.Controls;assembly=Microsoft.LightSwitch.Client.Internal"

    You can then access the controls from <ls:.... >

    I'm going to try my hand at making a Lightswitch extension for a UTC DateTime control, if I'm successful, I'll post it in the Gallery.

    • Ditandai sebagai Jawaban oleh ElylV 07 Maret 2012 14:25
    • Tanda sebagai Jawaban dihapus oleh ElylV 13 Maret 2012 12:35
    •  
  • 08 Maret 2012 7:34
     
     
    Thanks for sharing!
  • 13 Maret 2012 12:26
     
     

    After my initial excitement at finding the right control and reference, I've run into a bit of a problem actually using it.

    The DateTimePickerVisual displays fine in my custom control, however, it only shows the date, and it only shows it in short format.
    There are booleans for ShowTime and LongDate available in the XAML, but these have no effect.
    I also don't see which property to bind to in the control either.

    Has anyone used this control before, or any other of Lightswitch's own controls?  Is there a special way to set their attributes and bind to their values?

  • 20 Agustus 2012 15:53
     
     

    I have followed your example to achieve the same goal, but instead on using DateTimePickerVisual I used BaseDatePicker, and I used SelectedDate to do my binding.

    But I only get the date on screen, and I have not find the way to get the TimePicker which is part of the assembly Microsoft.LightSwitch.Presentation.Framework.Toolkit.Internal. I referenced the assembly, but I don't see the TimePicker.

    Have you managed to resolve your issue? If so how did you managed it ?

  • 21 Agustus 2012 7:35
     
     
    Yes I used a combined BaseDatePicker and also BaseTimePicker to make my own DateTime picker.  You can find my control in my LS extensions (link below) if it's just a UTC DateTime control you're after.

    Free Visual Studio LightSwitch extensions: Elyl's Extensions http://visualstudiogallery.msdn.microsoft.com/bbe013bf-45b6-46c4-ba13-537cc23c5118

  • 30 Agustus 2012 6:22
     
     

    I tried to use your extension, but I am still on visual studio 2010 and get a manifest error on your file.

    I am having trouble with the LS BaseDatePicker, which throws me an error HRESULT_EFAIL and cannot build a control based on the LS DatePicker.

    Would you be able to share the code of your UTC DateTime for me to have a look at?

    Thank you in advance...

  • 30 Agustus 2012 8:08
     
     

    Hi Manu,

    So, you need to add this namespace:
    xmlns:ls="clr-namespace:Microsoft.LightSwitch.Presentation.Implementation.Controls;assembly=Microsoft.LightSwitch.Client.Internal"

    Then the controls are added like:
    <ls:BaseDatePicker />

    <ls:BaseTimePicker />

    Your codebehind needs to take care of exposing a single datetime property and splitting that into a value for the basedatepicker and one for the basetimepicker.

    Don't worry about the HRESULT_EFAIL, as I think I got this error but it doesn't stop the project from building correctly.


    Free Visual Studio LightSwitch extensions: Elyl's Extensions http://visualstudiogallery.msdn.microsoft.com/bbe013bf-45b6-46c4-ba13-537cc23c5118