@@ -440,6 +440,11 @@ public event EventHandler<CurrentSelectionChangedEventArgs> SelectionChanged
440440 }
441441 }
442442
443+ /// <summary>
444+ /// Occurs when the <see cref="DisplayMode"/> property is changed.
445+ /// </summary>
446+ public event EventHandler < EventArgs > DisplayModeChanged ;
447+
443448 /// <summary>
444449 /// Gets the <see cref="CommandService"/> instance that manages the commanding behavior of this instance.
445450 /// </summary>
@@ -2207,87 +2212,87 @@ internal void UpdateNavigationHeaderContent()
22072212 return ;
22082213 }
22092214
2210- if ( this . HeaderContent == null )
2215+ string headerContent = null ;
2216+ switch ( this . DisplayMode )
22112217 {
2212- string headerContent = null ;
2213-
2214- switch ( this . DisplayMode )
2215- {
2216- case CalendarDisplayMode . MonthView :
2217- headerContent = string . Format ( this . currentCulture , this . MonthViewHeaderFormat , this . DisplayDate ) ;
2218- break ;
2219- case CalendarDisplayMode . YearView :
2220- headerContent = string . Format ( this . currentCulture , this . YearViewHeaderFormat , this . DisplayDate ) ;
2221- break ;
2222- case CalendarDisplayMode . DecadeView :
2223- DateTime decadeStart = CalendarMathHelper . GetFirstDateOfDecade ( this . DisplayDate ) ;
2224- DateTime decadeEnd = decadeStart . AddYears ( 9 ) ;
2218+ case CalendarDisplayMode . MonthView :
2219+ headerContent = string . Format ( this . currentCulture , this . MonthViewHeaderFormat , this . DisplayDate ) ;
2220+ break ;
2221+ case CalendarDisplayMode . YearView :
2222+ headerContent = string . Format ( this . currentCulture , this . YearViewHeaderFormat , this . DisplayDate ) ;
2223+ break ;
2224+ case CalendarDisplayMode . DecadeView :
2225+ DateTime decadeStart = CalendarMathHelper . GetFirstDateOfDecade ( this . DisplayDate ) ;
2226+ DateTime decadeEnd = decadeStart . AddYears ( 9 ) ;
22252227
2226- headerContent = string . Format ( this . currentCulture , this . DecadeViewHeaderFormat , decadeStart , decadeEnd ) ;
2227- break ;
2228- case CalendarDisplayMode . CenturyView :
2229- DateTime centuryStart = CalendarMathHelper . GetFirstDateOfCentury ( this . DisplayDate ) ;
2230- DateTime centuryEnd = centuryStart . AddYears ( 99 ) ;
2228+ headerContent = string . Format ( this . currentCulture , this . DecadeViewHeaderFormat , decadeStart , decadeEnd ) ;
2229+ break ;
2230+ case CalendarDisplayMode . CenturyView :
2231+ DateTime centuryStart = CalendarMathHelper . GetFirstDateOfCentury ( this . DisplayDate ) ;
2232+ DateTime centuryEnd = centuryStart . AddYears ( 99 ) ;
22312233
2232- headerContent = string . Format ( this . currentCulture , this . CenturyViewHeaderFormat , centuryStart , centuryEnd ) ;
2233- break ;
2234- case CalendarDisplayMode . MultiDayView :
2235- string headerText = this . MultiDayViewSettings . MultiDayViewHeaderText ;
2236- if ( string . IsNullOrEmpty ( headerText ) )
2234+ headerContent = string . Format ( this . currentCulture , this . CenturyViewHeaderFormat , centuryStart , centuryEnd ) ;
2235+ break ;
2236+ case CalendarDisplayMode . MultiDayView :
2237+ string headerText = this . MultiDayViewSettings . MultiDayViewHeaderText ;
2238+ if ( string . IsNullOrEmpty ( headerText ) )
2239+ {
2240+ DateTime firstDateOfCurrentWeek = this . DisplayDate ;
2241+ DateTime lastDayOfWeek ;
2242+ int visibleDays = this . MultiDayViewSettings . VisibleDays ;
2243+ if ( this . MultiDayViewSettings . WeekendsVisible )
22372244 {
2238- DateTime firstDateOfCurrentWeek = this . DisplayDate ;
2239- DateTime lastDayOfWeek ;
2240- int visibleDays = this . MultiDayViewSettings . VisibleDays ;
2241- if ( this . MultiDayViewSettings . WeekendsVisible )
2242- {
2243- lastDayOfWeek = firstDateOfCurrentWeek . AddDays ( visibleDays ) ;
2244- }
2245- else
2246- {
2247- firstDateOfCurrentWeek = CalendarMathHelper . SetFirstAvailableBusinessDay ( firstDateOfCurrentWeek , 1 ) ;
2248- lastDayOfWeek = CalendarMathHelper . AddBusinessDays ( firstDateOfCurrentWeek , visibleDays ) ;
2249- }
2245+ lastDayOfWeek = firstDateOfCurrentWeek . AddDays ( visibleDays ) ;
2246+ }
2247+ else
2248+ {
2249+ firstDateOfCurrentWeek = CalendarMathHelper . SetFirstAvailableBusinessDay ( firstDateOfCurrentWeek , 1 ) ;
2250+ lastDayOfWeek = CalendarMathHelper . AddBusinessDays ( firstDateOfCurrentWeek , visibleDays ) ;
2251+ }
22502252
2251- if ( visibleDays == 1 )
2252- {
2253- string format = "{0:d MMMM yyyy}" ;
2254- headerContent = string . Format ( this . currentCulture , format , firstDateOfCurrentWeek ) ;
2255- }
2256- else
2257- {
2258- string format = firstDateOfCurrentWeek . Year == lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) . Year ?
2259- ( firstDateOfCurrentWeek . Month == lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) . Month ?
2260- "{0:d } ~ {1:d MMMM yyyy}" :
2261- "{0:d MMMM} ~ {1:d MMMM yyyy}" ) :
2262- "{0:d MMMM yyyy} ~ {1:d MMMM yyyy}" ;
2263-
2264- lastDayOfWeek = lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) ;
2265- if ( ! this . MultiDayViewSettings . WeekendsVisible )
2266- {
2267- lastDayOfWeek = CalendarMathHelper . SetFirstAvailableBusinessDay ( lastDayOfWeek , - 1 ) ;
2268- }
2269-
2270- headerContent = string . Format ( this . currentCulture , format , firstDateOfCurrentWeek , lastDayOfWeek ) ;
2271- }
2253+ if ( visibleDays == 1 )
2254+ {
2255+ string format = "{0:d MMMM yyyy}" ;
2256+ headerContent = string . Format ( this . currentCulture , format , firstDateOfCurrentWeek ) ;
22722257 }
22732258 else
22742259 {
2275- headerContent = headerText ;
2260+ string format = firstDateOfCurrentWeek . Year == lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) . Year ?
2261+ ( firstDateOfCurrentWeek . Month == lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) . Month ?
2262+ "{0:d } ~ {1:d MMMM yyyy}" :
2263+ "{0:d MMMM} ~ {1:d MMMM yyyy}" ) :
2264+ "{0:d MMMM yyyy} ~ {1:d MMMM yyyy}" ;
2265+
2266+ lastDayOfWeek = lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) ;
2267+ if ( ! this . MultiDayViewSettings . WeekendsVisible )
2268+ {
2269+ lastDayOfWeek = CalendarMathHelper . SetFirstAvailableBusinessDay ( lastDayOfWeek , - 1 ) ;
2270+ }
2271+
2272+ headerContent = string . Format ( this . currentCulture , format , firstDateOfCurrentWeek , lastDayOfWeek ) ;
22762273 }
2274+ }
2275+ else
2276+ {
2277+ headerContent = headerText ;
2278+ }
22772279
2278- break ;
2279- }
2280+ break ;
2281+ }
22802282
2283+ if ( this . HeaderContent == null )
2284+ {
22812285 this . navigationPanel . HeaderContent = headerContent ;
22822286 }
22832287 else
22842288 {
22852289 this . navigationPanel . HeaderContent = this . HeaderContent ;
2290+ this . navigationPanel . DataContext = headerContent ;
22862291 }
22872292
22882293 this . navigationPanel . HeaderContentTemplate = this . HeaderContentTemplate ;
22892294 }
2290-
2295+
22912296 internal void OnCalendarButtonClicked ( )
22922297 {
22932298 this . FooterButtonClicked ? . Invoke ( this , EventArgs . Empty ) ;
@@ -2681,6 +2686,8 @@ private static void OnDisplayModePropertyChanged(DependencyObject target, Depend
26812686 calendar . FetchNewAppointments ( ) ;
26822687 calendar . model . multiDayViewModel . updateFlag = MultiDayViewUpdateFlag . All ;
26832688 }
2689+
2690+ calendar . DisplayModeChanged ? . Invoke ( calendar , new EventArgs ( ) ) ;
26842691 }
26852692
26862693 private static void OnCalendarViewHeaderFormatPropertyChanged ( DependencyObject sender , DependencyPropertyChangedEventArgs args )
0 commit comments