@@ -2207,87 +2207,87 @@ internal void UpdateNavigationHeaderContent()
22072207 return ;
22082208 }
22092209
2210- if ( this . HeaderContent == null )
2210+ string headerContent = null ;
2211+ switch ( this . DisplayMode )
22112212 {
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 ) ;
2213+ case CalendarDisplayMode . MonthView :
2214+ headerContent = string . Format ( this . currentCulture , this . MonthViewHeaderFormat , this . DisplayDate ) ;
2215+ break ;
2216+ case CalendarDisplayMode . YearView :
2217+ headerContent = string . Format ( this . currentCulture , this . YearViewHeaderFormat , this . DisplayDate ) ;
2218+ break ;
2219+ case CalendarDisplayMode . DecadeView :
2220+ DateTime decadeStart = CalendarMathHelper . GetFirstDateOfDecade ( this . DisplayDate ) ;
2221+ DateTime decadeEnd = decadeStart . AddYears ( 9 ) ;
22252222
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 ) ;
2223+ headerContent = string . Format ( this . currentCulture , this . DecadeViewHeaderFormat , decadeStart , decadeEnd ) ;
2224+ break ;
2225+ case CalendarDisplayMode . CenturyView :
2226+ DateTime centuryStart = CalendarMathHelper . GetFirstDateOfCentury ( this . DisplayDate ) ;
2227+ DateTime centuryEnd = centuryStart . AddYears ( 99 ) ;
22312228
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 ) )
2229+ headerContent = string . Format ( this . currentCulture , this . CenturyViewHeaderFormat , centuryStart , centuryEnd ) ;
2230+ break ;
2231+ case CalendarDisplayMode . MultiDayView :
2232+ string headerText = this . MultiDayViewSettings . MultiDayViewHeaderText ;
2233+ if ( string . IsNullOrEmpty ( headerText ) )
2234+ {
2235+ DateTime firstDateOfCurrentWeek = this . DisplayDate ;
2236+ DateTime lastDayOfWeek ;
2237+ int visibleDays = this . MultiDayViewSettings . VisibleDays ;
2238+ if ( this . MultiDayViewSettings . WeekendsVisible )
22372239 {
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- }
2240+ lastDayOfWeek = firstDateOfCurrentWeek . AddDays ( visibleDays ) ;
2241+ }
2242+ else
2243+ {
2244+ firstDateOfCurrentWeek = CalendarMathHelper . SetFirstAvailableBusinessDay ( firstDateOfCurrentWeek , 1 ) ;
2245+ lastDayOfWeek = CalendarMathHelper . AddBusinessDays ( firstDateOfCurrentWeek , visibleDays ) ;
2246+ }
22502247
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- }
2248+ if ( visibleDays == 1 )
2249+ {
2250+ string format = "{0:d MMMM yyyy}" ;
2251+ headerContent = string . Format ( this . currentCulture , format , firstDateOfCurrentWeek ) ;
22722252 }
22732253 else
22742254 {
2275- headerContent = headerText ;
2255+ string format = firstDateOfCurrentWeek . Year == lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) . Year ?
2256+ ( firstDateOfCurrentWeek . Month == lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) . Month ?
2257+ "{0:d } ~ {1:d MMMM yyyy}" :
2258+ "{0:d MMMM} ~ {1:d MMMM yyyy}" ) :
2259+ "{0:d MMMM yyyy} ~ {1:d MMMM yyyy}" ;
2260+
2261+ lastDayOfWeek = lastDayOfWeek . Subtract ( TimeSpan . FromTicks ( 1 ) ) ;
2262+ if ( ! this . MultiDayViewSettings . WeekendsVisible )
2263+ {
2264+ lastDayOfWeek = CalendarMathHelper . SetFirstAvailableBusinessDay ( lastDayOfWeek , - 1 ) ;
2265+ }
2266+
2267+ headerContent = string . Format ( this . currentCulture , format , firstDateOfCurrentWeek , lastDayOfWeek ) ;
22762268 }
2269+ }
2270+ else
2271+ {
2272+ headerContent = headerText ;
2273+ }
22772274
2278- break ;
2279- }
2275+ break ;
2276+ }
22802277
2278+ if ( this . HeaderContent == null )
2279+ {
22812280 this . navigationPanel . HeaderContent = headerContent ;
22822281 }
22832282 else
22842283 {
22852284 this . navigationPanel . HeaderContent = this . HeaderContent ;
2285+ this . navigationPanel . DataContext = headerContent ;
22862286 }
22872287
22882288 this . navigationPanel . HeaderContentTemplate = this . HeaderContentTemplate ;
22892289 }
2290-
2290+
22912291 internal void OnCalendarButtonClicked ( )
22922292 {
22932293 this . FooterButtonClicked ? . Invoke ( this , EventArgs . Empty ) ;
0 commit comments