We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfDateSelector Styling and 'Accepted' Event Handling

Hi.

I like the feature of the SFDatePicker control to set the value to null, which comes in pretty handy in my app. A couple of things I haven't figured out yet:

I want the user to be able to accept a pre-selected (proposed) date. A ValueChanged event does not fire in that case because the user is not changing the date. I'd like to be able to catch the event "user confirms pre-selected date" vs. "user cancels" (date remains not set). However, when the date is not changed, tapping the checkmark is pretty much the same as tapping the cancel or back button, or is there a way to handle the accept/checkmark button tapped event?

Can I style the selector so that it fills the entire screen similar to the standard Windows DatePicker? Standard dimension and alignment properties applied to the date selector don't seem to do the trick. Only the Width property could be set to an absolute value. The Height property has no effect, and neither do the HorizontalAlignment and VerticalAlignment properties.

-Jürgen

7 Replies

VJ Victory Jessie Selvam D Syncfusion Team April 20, 2015 06:39 AM UTC

Hi Jürgen,

Thank you for using Syncfusion products.

Query #1:is there a way to handle the accept/checkmark button tapped event?
We have prepared a sample and tried to meet your requirement. In the sample, we have retrieved the buttons from SfDateSelector using VisualTreeHelper and hooked the Tapped events.

Query #2: Can I style the selector so that it fills the entire screen?
Yes. You can style the selector to fill entire screen by setting the DropDownHeight property in SfDatePicker and Width of SfDateSelector in SelectorStyle property. Please download the sample from following link,

Sample: DateSelector.zip

Please let us know whether the provided sample meets your requirement or not.

Regards,
Jessie


Jürgen April 20, 2015 11:02 AM UTC


Hi Jessie.

Thank you. That looks good.

We have prepared a sample and tried to meet your requirement. In the sample, we have retrieved the buttons from SfDateSelector using VisualTreeHelper and hooked the Tapped events.

Great. That definitely does the job. Interesting phenomenon though: every time you close the selector using one of the buttons, the number of times the corresponding handler fires increases -- once the first time, twice the second time, and so on. Not a severe issue as I don't expect the user to change the date many times at once.

Yes. You can style the selector to fill entire screen by setting the DropDownHeight property in SfDatePicker and Width of SfDateSelector in SelectorStyle property. Please download the sample from following link,

OK. This requires setting the properties in code behind after determining the screen dimensions, correct? DropDownHeight is straightforward. How about setting the selector Width?

Thanks and regards,
-Jürgen








BK Bharadhi K Syncfusion Team April 21, 2015 01:03 PM UTC

Hi Jurgen,

Thank you for the update.

Query 1: every time you close the selector using one of the buttons, the number of times the corresponding handler fires increases

While checking the issue we found that the Tapped event is hooked every time the Selector is opened. We have modified the sample to resolve this. In the sample, we have defined a temporary bool variable "handled" and hooked the event only once based on the handled variable.

Query 2: This requires setting the properties in code behind after determining the screen dimensions, correct? How about setting the selector Width?

In the previous update, we had set the Width of the SfDateSelector in the SelectorStyle property to define in Xaml. We can also set the width in code-behind by retrieving the Selector from SfDatePicker and assigning the width. We have modified the sample to demonstrate the same. In the sample we have set the Width of the Selector in the dropdownpopup_Opened event.

Please find the sample in the below link.

Sample: DateSelector.zip

Please let us know if you require further assistance on this.

Regards,
Bharadhi K


Jürgen April 22, 2015 06:57 PM UTC

Hi Bharadhi.

Thank you for your effort and for the code sample. I very much appreciate that.

About the repeated execution of the event handlers:
Yes, thank you. I had something similar in mind, but this works very well.

About expanding the selector across the entire screen:
This works well in Windows. It almost works well on WP, except for a little offset probably caused by the status bar. Since Win8.1 getting the height of that isn't that clear. Also, it does not handle screen rotation very well. I can update the width and height attributes in a Window SizeChanged event handler but there remains a vertical offset.

Overall, this is quite a bit of tweaking needed to get a basic view. In future versions of this control, it would be good to be able to expose this via a couple of simple properties of the parent control, so this can be easily set in XAML or styled. The full-screen view is still the most usable and visually attractive, at least on a Phone.  But I understand that the priority and need for this control may have decreased a bit after Microsoft released their DatePicker (I understood it wasn't there in WinRT from the beginning). Still, the option to set the SfDatePicker value to null and show it empty is a great advantage over the standard control.

Many thanks and best regards,
-Jürgen


VJ Victory Jessie Selvam D Syncfusion Team April 23, 2015 01:42 PM UTC

Hi Jürgen,

Thanks for your suggestions and we will consider your suggestions as a feature in our upcoming releases.

Regards,
Jessie


Jürgen April 23, 2015 08:28 PM UTC

Hi Jessie.

Thank you. I really appreciate everyone's effort. But, at the end, it either works or it doesn't - half-way isn't enough. Hooking up the accept and cancel events is absolutely cool. But right now, the SfDatePicker with default style does not look good on a Windows Phone. We did some tweaking here but it's really only half a solution. I made a feature request based on this discussion, and I would really like to see this being given some serious consideration.

Thanks and regards,
-Juergen


VJ Victory Jessie Selvam D Syncfusion Team April 24, 2015 12:58 PM UTC

Hi Jürgen,

Thank you for your suggestions.

We could find that you have already created a incident with following suggestions. We request to follow up with the incident for further updates.

Please let us know if you have any questions.

Regards,
Jessie

Loader.
Live Chat Icon For mobile
Up arrow icon