private void CalendarView_SelectedDatesChanged(Windows.UI.Xaml.Controls.CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args) { DateTimeOffset selectedDateTimeOffset = sender.SelectedDates.FirstOrDefault(); //Get selected DateTimeOffset DateTime selectedDateTime = selectedDateTimeOffset.UtcDateTime; //Convert to DateTime if (selectedDateTime != null) { } }
private void CalendarView_CalendarViewDayItemChanging(Windows.UI.Xaml.Controls.CalendarView sender, CalendarViewDayItemChangingEventArgs args) { if (args.Phase == 0) { args.RegisterUpdateCallback(CalendarView_CalendarViewDayItemChanging); } List <Color> densityColors = new List <Color>(); foreach (OrdersSharedMailing _sharedMailing in sharedMailing) { if (_sharedMailing.sharedDate.Date == args.Item.Date.Date) { densityColors.Add(Color.FromArgb(255, 52, 61, 146)); break; } } foreach (OrdersDirectMailing _directMailing in directMailing) { if (_directMailing.directDate.Date == args.Item.Date.Date) { densityColors.Add(Color.FromArgb(255, 26, 154, 213)); break; } } foreach (OrdersSchoolSend _schoolSend in schoolSend) { if (_schoolSend.schoolsendEnd.Date == args.Item.Date.Date) { densityColors.Add(Color.FromArgb(255, 39, 179, 75)); break; } } foreach (OrdersEmail _email in email) { if (_email.emailDate.Date == args.Item.Date.Date) { densityColors.Add(Color.FromArgb(255, 242, 182, 17)); break; } } args.Item.SetDensityColors(densityColors); }
// Handle the custom property changed event and call the OnPropertyChanged methods. internal override void OnPropertyChanged2( DependencyPropertyChangedEventArgs args) { base.OnPropertyChanged2(args); //if (args.m_pDP.GetIndex() == KnownPropertyIndex.CalendarViewDayItem_IsBlackout) if (args.Property == IsBlackoutProperty) { bool isBlackout = false; isBlackout = (bool)args.NewValue; SetIsBlackout(isBlackout); // when setting an item to blackout, we need remove it from selectedDates (if it exists) if (isBlackout) { CalendarView spParentCalendarView = GetParentCalendarView(); if (spParentCalendarView is {})
private void GetColumnHeaderItemsImpl(out uint pReturnValueCount, out IRawElementProviderSimple[] ppReturnValue) { pReturnValueCount = 0; ppReturnValue = default; UIElement spOwner; spOwner = Owner; DateTime date; date = ((CalendarViewDayItem)spOwner).Date; CalendarView pParent = (spOwner as CalendarViewDayItem).GetParentCalendarView(); uint nCount = 0; Grid spWeekDayNames; // Gets the 'WeekDayNames' part of the container template and find weekindex position as elment spWeekDayNames = pParent.GetTemplateChild("WeekDayNames") as Grid; if (spWeekDayNames is {})
private int ColumnImpl() { var pValue = 0; UIElement spOwner; spOwner = Owner; DateTime date; date = (spOwner as CalendarViewItem).DateBase; CalendarView pParent = (spOwner as CalendarViewItem).GetParentCalendarView(); CalendarViewGeneratorHost spHost; pParent.GetActiveGeneratorHost(out spHost); CalendarPanel pCalendarPanel = spHost.Panel; if (pCalendarPanel is {})
internal override void PrepareItemContainer( DependencyObject pContainer, object pItem) { DateTime date; CalendarViewDayItem spContainer; spContainer = (CalendarViewDayItem)(pContainer); // first let's check if this container is already in the tobecleared queue // the container might be already marked as to be cleared but not cleared yet, // if we pick up this container we don't need to clear it up. RemoveToBeClearedContainer(spContainer); // now prepare the container date = (DateTime)pItem; GetCalendar().SetDateTime(date); spContainer.Date = date; // main text { string mainText; mainText = GetCalendar().DayAsString(); spContainer.UpdateMainText(mainText); } // label text { bool isLabelVisible = false; isLabelVisible = Owner.IsGroupLabelVisible; UpdateLabel(spContainer, isLabelVisible); } // today state will be updated in CalendarViewGeneratorHost.PrepareItemContainer // clear the blackout state and set correct selection state. { // we don't have a copy of blackout items (that could be too many), instead developer needs to tell us // about the blackout and densitybar properties when in CIC event. As both properties are on the container (not like selected dates) so when // the container is being reused, we'll need to clear these properties and developer may set them again if they want. // there is a discussion that who should clear the flags - the developer clear them in phase 0 (in CIC phase 0 event) // or we clear them in phase 0 (before CIC phase 0 event). the result is we do this to make the logical simple. // reset the blackout state spContainer.IsBlackout = false; // set selection state. bool isSelected = false; Owner.IsSelected(date, out isSelected); spContainer.SetIsSelected(isSelected); } // clear the density bar as well. #if CALENDARVIEW_DENSITYCOLORS_SUPPORTED // UNO-TODO: .SetDensityColors() not implemented yet spContainer.SetDensityColors(null); #endif // apply style to CalendarViewDayItem if any. { Style spStyle; spStyle = Owner.CalendarViewDayItemStyle; CalendarView.SetDayItemStyle(spContainer, spStyle); } base.PrepareItemContainer(pContainer, pItem); }
internal CalendarViewAutomationPeer(CalendarView owner) : base(owner) { }