|
public ICommand OkCommand => new Command(OkButton);
private void OkButton(object obj)
{
// you can get the selected date
var datePicker = obj as Syncfusion.SfPicker.XForms.SelectionChangedEventArgs;
var date = GetSelectedItems(datePicker.NewValue as ICollection);
} |
Hi All,
I have sfdatepickers with default day, month, year style is there any way to customized the month/year/day data with my own data source( like to change the date selection into 00-99(year), A - L(month), 00 - 31(day) ) instead the default values.
Hello @Jeya Kasipandi,
Thanks for the demo, further on this can you help me on how to get the selected value of Month,Year,Day on click of footer OK button I'm following the MVVM pattern?
Thanks
Shankar
| void OnOkClicked(Object obj)
{
var selectedItemValue = (obj as Syncfusion.SfPicker.XForms.SelectionChangedEventArgs).NewValue;
}
public ViewModel()
{
OkCommand = new Command<Object>(OnOkClicked);
} |
| <local:CustomDatePicker.Behaviors>
<local:EventToCommandBehavior EventName="OkButtonClicked" Command="{Binding OkCommand}" />
</local:CustomDatePicker.Behaviors> </local:CustomDatePicker> |
Hi Jeya K,
Thanks for the help and updated demo based on my requirement it works now, moreover I could not find any property to set the font size of footer buttons (OK/Cancel), can you help me on that?
Thanks
Shankar
| <local:CustomDatePicker.FooterView>
<StackLayout Orientation="Horizontal" >
<Button Text="OK" WidthRequest="70" Command="{Binding OkCommand}" HorizontalOptions="EndAndExpand"></Button>
<Button Text="Cancel" WidthRequest="80" Clicked="Button_Clicked_2" HorizontalOptions="EndAndExpand"></Button>
</StackLayout> </local:CustomDatePicker.FooterView> |
Thanks for the update Jeya K, really appreciate for the effort given.
Moreover In this demo month picker is configured as A-L values means (Jan to Dec), so how can I achieve below points.
1- Days are not related to the month (can select 1-31 days in all moth). Leap years must be taken into account (e.g. if we could select February 29, 2020),
2- on opening of the picker it should display defaulted to today's date.
looking forward to hearing from you at earliest.
Thanks
Shankar
@
Jeya Kasipandi @
Syncfusion Team
kindly revert the solution as i'm in the middle of it, waiting for your response.
Thanks
Shankar
| Months = new Dictionary<string, string>();
ObservableCollection<object> todaycollection = new ObservableCollection<object>();
int j= 65;
for (int i = 1; i < 13; i++)
{
if(!Months.ContainsKey(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3)))
Months.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i).Substring(0, 3), ((char)j).ToString());
j++;
}
//Select today dates
var mon=CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Date.Month).Substring(0, 3);
todaycollection.Add(Months[mon]);
todaycollection.Add(DateTime.Now.Date.Year.ToString());
if (DateTime.Now.Date.Day < 10)
todaycollection.Add("0" + DateTime.Now.Date.Day);
else
todaycollection.Add(DateTime.Now.Date.Day.ToString()); this.StartDate = todaycollection; |
Hi @ Jeya Kasipandi,
I would like to really appreciate for the effort given for such customization, everything is ok now except one small concern.
Query 1 :
Its perfectly working as expected.
Query 2: On opening of the picker, it should display defaulted to today's date.
date picker default date value is working fine for Months & Day picker but not for the Year picker(see the attached screenshot.
As you quoted above year has been added from 0 to 99 . So, the current date is not displayed in picker,
moreover month picker value is also customized as (A-L) and working with defaulted value, likewise is there any way to customize the year picker to with customized data source(like months dictionary) so that it can show the current year selected too?
| var year = DateTime.Now.Date.Year.ToString(); todaycollection.Add(year.Substring(2,2)); |
Hello @Jeya Kasipandi,
Appreciate it, it's working now.
one thing year taking from 0-99 it is throwing an exception "Date can't be zero it must be between 1-9999" although no issue between 1-99. is there anything need to change for 0-99?
Regards,
Shankar
Thank you, got it.
Regards,
Shankar
Hi Shankar,
Thanks for the update. Let me know if you have any other concerns.
Regards,
Ruba Shanmugam