none
DatePicker as Custom Control in LightSwitch RRS feed

  • Question

  • I'm a new LightSwitch fan, and for learning purposes, i tried to develope a simple data entry application, every thing worked well, but i stopped when i faced the custom controls like the following:

    I've added a "Custom Control" of type "DatePicker" into my screen and without a binding source, i want to set and get value from it when i press a button for example, would u please tell me how...

    Saturday, March 24, 2012 11:41 AM

Answers

  • Hi

    As i mentioned in code, you have to write this code when your screen is activated. For more info please read this.

    Follow the below steps. Don't forget to add reference. As here i am adding Telerik.Windows.Controls.Input

    I think now you can able to understand.


    Rashmi Ranjan Panigrahi

    • Marked as answer by AyhamM Sunday, March 25, 2012 9:57 AM
    Sunday, March 25, 2012 8:54 AM

All replies

  • Hi

    You may want to have a look at this article

    http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/2/Creating-A-LightSwitch-Custom-Silverlight-Control.aspx

    It should give you some ideas on implementing custom controls. With your datepicker, you would add it to your own control and set the Value property to a binding like 'Screen.Order.OrderDate'. This will bind to 'Screen.Order.OrderDate' all the time.

    If you want to reuse the control, you can set the Binding to 'Value' and then set the Binding on the Lightswitch side to your desired value when you add the control to the screen.

    As a newbie to Lightswitch, I recommend you read the above article and many others on that site. The Student Information System is a great application to get you acquainted with Lightswitch.

    Regards and good luck

    Paul

    Saturday, March 24, 2012 2:01 PM
  • Hi

    You can use something same like below code to get the result. In my case i am using telerik RadDatePicker.

    You can change your assembly and code as per your requirement.

    partial void YourScreen_Activated()
            {
                // Write your code here.
                IContentItemProxy datePicker = this.FindControl("EstimateDate");
                datePicker.SetBinding(Telerik.Windows.Controls.RadDatePicker.SelectedDateProperty, "Screen.EstimateProperty.EstimateDate", System.Windows.Data.BindingMode.TwoWay);
            }
    May this help you...

    Rashmi Ranjan Panigrahi


    • Edited by babloo1436 Saturday, March 24, 2012 2:32 PM
    Saturday, March 24, 2012 2:32 PM
  • Thanks for reply,

    but would u please explain why when i wrote (System.Windows.Controls.datepicker)

    the error message was (datepicker is not a member of Controls )

    Regards,

    Ayham

    Sunday, March 25, 2012 6:48 AM
  • Hi

    As i mentioned in code, you have to write this code when your screen is activated. For more info please read this.

    Follow the below steps. Don't forget to add reference. As here i am adding Telerik.Windows.Controls.Input

    I think now you can able to understand.


    Rashmi Ranjan Panigrahi

    • Marked as answer by AyhamM Sunday, March 25, 2012 9:57 AM
    Sunday, March 25, 2012 8:54 AM