I need to be able to disable the selection of future dates within the Silverlight DatePicker control - any ideas ?
http://msdn.microsoft.com/en-us/library/system.windows.controls.datepicker.displaydateend(VS.95).aspx
DatePicker.DisplayDateEnd = DateTime.Now;
?
Use the MaxDate to Blackout the future dates
System.DateTime DatesDisplayEnd = today.Add(duration);
System.DateTime MaxDate = DateTime.MaxValue;
stkDatePicker.BlackoutDates.Add(new CalendarDateRange(DatesDisplayEnd, MaxDate));
Related
How to restrict DateTimePicker to select the time only? I don't know how to disable calendar control which drops when you press the button at the right of DateTimePicker.
A snippet out of the MSDN:
'The following code sample shows how
to create a DateTimePicker that
enables users to choose a time only.'
timePicker = new DateTimePicker();
timePicker.Format = DateTimePickerFormat.Time;
timePicker.ShowUpDown = true;
And for anyone who wants to know what it looks like:
...or alternatively if you only want to show a portion of the time value use "Custom":
timePicker = new DateTimePicker();
timePicker.Format = DateTimePickerFormat.Custom;
timePicker.CustomFormat = "HH:mm"; // Only use hours and minutes
timePicker.ShowUpDown = true;
You want to set its 'Format' property to be time and add a spin button control to it:
yourDateTimeControl.Format = DateTimePickerFormat.Time;
yourDateTimeControl.ShowUpDown = true;
If you want to do it from properties, you can do this by setting the Format property of DateTimePicker to DateTimePickerFormat.Time and ShowUpDown property to true. Also, customFormat can be set in properties.
The best way to do this is this:
datetimepicker.Format = DatetimePickerFormat.Custom;
datetimepicker.CustomFormat = "HH:mm tt";
datetimepicker.ShowUpDowm = true;
Add below event to DateTimePicker
Private Sub DateTimePicker1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles DateTimePicker1.KeyPress
e.Handled = True
End Sub
I have develop an MVC C# application, published in Somee.
Only in Somee I have a problem with datetime format (US vs IT)
I have a typed list view whit, for each row, a date field and
same record edited in a partial view.
Data Annotation class:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime DataCons { get; set; }
In list view I used:
<td>#Html.EditorFor(Model => Model[c].DataCons, "{0:dd/MM/yyyy}", new { #style = "width: 140px;" })</td>
and a calendar is used and no problem with date time format
In partial view for editing record, same code used in list view doesn' t work and I need to use TextBoxFor instead EditorFor, a model binder to convert datetime format and a javascript date-picker.
#Html.TextBoxFor(m => m.Scadenza, "{0:dd/MM/yyyy}", new { #class = "date-picker", style = "width: 90px;" })
A way to unify my code maybe setting somee language setting?
Regards
I am creating an event to my calendar and added an attendees to that event. As specified in the doc here We can prevent the event from editing by the attendees. But it's now working as expected. Can anyone help me.
Here's how I am trying....
Event event = new Event().setSummary("sampleEvent").setDescription("eventsummary");
DateTimeHelper obDateTimeHelper = new DateTimeHelper();
DateTime startDateTime = new DateTime(obDateTimeHelper.funGetNowInMillisecondsInThisTimeZone("UTC"));
EventDateTime start = new EventDateTime().setDateTime(startDateTime).setTimeZone("UTC");
event.setStart(start);
DateTime endDateTime = new DateTime(obDateTimeHelper.funGetNowInMillisecondsInThisTimeZone("UTC"));
EventDateTime end = new EventDateTime().setDateTime(endDateTime).setTimeZone("UTC");
event.setEnd(end);
event.setLocked(true);
event.setVisibility("private");
event.setGuestsCanInviteOthers(false);
event.setGuestsCanModify(false);
event.setGuestsCanSeeOtherGuests(false);
EventAttendee[] attendee = new EventAttendee[]{ new EventAttendee().setEmail("attendee#gmail.com") };
event.setAttendees(Arrays.asList(attendee));
Calendar calendarService = getCalendarService(accessToken);
event = calendarService.events().insert(calendarId, event).setOauthToken(accessToken).execute();
"This field is read-only." is at the end of the documentation to which you pointed. That means you cannot set this property yourself.
Can you please let me know how can I modify the silverlight toolkit date picker (toolkit:DatePicker) to work with hijri calendar
Regards.
Here we go the answer to your question which is tested on windows mobile 8
CultureInfo sa = new CultureInfo("ar-SA");
sa.DateTimeFormat.Calendar = new System.Globalization.HijriCalendar();
Thread.CurrentThread.CurrentCulture = sa;
// Sets the UI culture to Arabic (Saudi Arabia)
Thread.CurrentThread.CurrentUICulture = sa;
Is there a way to define a application wide format for the dates in Silvelight. So far I've tried to add this code in App_Startup:
CultureInfo culture = (CultureInfo)CultureInfo.CurrentCulture.Clone();
culture.DateTimeFormat.ShortDatePattern = "dd-MM-yyyy";
culture.DateTimeFormat.FullDateTimePattern = "dd-MM-yyyy";
culture.DateTimeFormat.ShortTimePattern = "dd-MM-yyyy";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
But all my date binding don't take this into consideration.
Regards,
Create a string resource in your App.xaml
<System.String x:Key="MyDateFormat">dd-MM-yyyy</System.String>
And use it as a static resource in your bindings' string format
<TextBlock Text={Binding MyDateProperty, StringFormat={StaticResource MyDateFormat}} />
I haven't tested this, but that would be my first try.
Try accepted answer from here - DateTime Not showing with currentculture format in Datagrid,ListView.
This works for WPF, you can try it for Silverlight to make it respect your culture.
There is a partial solution for this here: http://timheuer.com/blog/archive/2010/08/11/stringformat-and-currentculture-in-silverlight.aspx
This may not work at the application level though - you may need to apply the solution to various other classes e.g. your child windows.