@@ -440,6 +440,11 @@ public event EventHandler<CurrentSelectionChangedEventArgs> SelectionChanged
440
440
}
441
441
}
442
442
443
+ /// <summary>
444
+ /// Occurs when the <see cref="DisplayMode"/> property is changed.
445
+ /// </summary>
446
+ public event EventHandler < EventArgs > DisplayModeChanged ;
447
+
443
448
/// <summary>
444
449
/// Gets the <see cref="CommandService"/> instance that manages the commanding behavior of this instance.
445
450
/// </summary>
@@ -2207,87 +2212,87 @@ internal void UpdateNavigationHeaderContent()
2207
2212
return ;
2208
2213
}
2209
2214
2210
- if ( this . HeaderContent == null )
2215
+ string headerContent = null ;
2216
+ switch ( this . DisplayMode )
2211
2217
{
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 ) ;
2225
2227
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 ) ;
2231
2233
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 )
2237
2244
{
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
+ }
2250
2252
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 ) ;
2272
2257
}
2273
2258
else
2274
2259
{
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 ) ;
2276
2273
}
2274
+ }
2275
+ else
2276
+ {
2277
+ headerContent = headerText ;
2278
+ }
2277
2279
2278
- break ;
2279
- }
2280
+ break ;
2281
+ }
2280
2282
2283
+ if ( this . HeaderContent == null )
2284
+ {
2281
2285
this . navigationPanel . HeaderContent = headerContent ;
2282
2286
}
2283
2287
else
2284
2288
{
2285
2289
this . navigationPanel . HeaderContent = this . HeaderContent ;
2290
+ this . navigationPanel . DataContext = headerContent ;
2286
2291
}
2287
2292
2288
2293
this . navigationPanel . HeaderContentTemplate = this . HeaderContentTemplate ;
2289
2294
}
2290
-
2295
+
2291
2296
internal void OnCalendarButtonClicked ( )
2292
2297
{
2293
2298
this . FooterButtonClicked ? . Invoke ( this , EventArgs . Empty ) ;
@@ -2681,6 +2686,8 @@ private static void OnDisplayModePropertyChanged(DependencyObject target, Depend
2681
2686
calendar . FetchNewAppointments ( ) ;
2682
2687
calendar . model . multiDayViewModel . updateFlag = MultiDayViewUpdateFlag . All ;
2683
2688
}
2689
+
2690
+ calendar . DisplayModeChanged ? . Invoke ( calendar , new EventArgs ( ) ) ;
2684
2691
}
2685
2692
2686
2693
private static void OnCalendarViewHeaderFormatPropertyChanged ( DependencyObject sender , DependencyPropertyChangedEventArgs args )
0 commit comments