C# Class Microsoft.Samples.KMoore.WPFSamples.DateControls.MonthCalendar

Inheritance: System.Windows.Controls.Control, IWeakEventListener
Exibir arquivo Open project: daszat/zetbox Class Usage Examples

Public Properties

Property Type Description
DataSourceDatePathProperty System.Windows.DependencyProperty
DataSourceDateXPathProperty System.Windows.DependencyProperty
DataSourceProperty System.Windows.DependencyProperty
DateSelectionChangedEvent System.Windows.RoutedEvent
DayContainerStyleProperty System.Windows.DependencyProperty
DayContainerStyleSelectorProperty System.Windows.DependencyProperty
DayHeaderStyleProperty System.Windows.DependencyProperty
DayTemplateProperty System.Windows.DependencyProperty
DayTemplateSelectorProperty System.Windows.DependencyProperty
FirstDayOfWeekProperty System.Windows.DependencyProperty
MaxDateProperty System.Windows.DependencyProperty
MaxSelectionCountProperty System.Windows.DependencyProperty
MinDateProperty System.Windows.DependencyProperty
NextButtonStyleProperty System.Windows.DependencyProperty
PreviousButtonStyleProperty System.Windows.DependencyProperty
SelectedDateProperty System.Windows.DependencyProperty
ShowsDayHeadersProperty System.Windows.DependencyProperty
ShowsTitleProperty System.Windows.DependencyProperty
ShowsWeekNumbersProperty System.Windows.DependencyProperty
TitleStyleProperty System.Windows.DependencyProperty
VisibleMonthChangedEvent System.Windows.RoutedEvent
VisibleMonthProperty System.Windows.DependencyProperty
WeekNumberStyleProperty System.Windows.DependencyProperty

Private Properties

Property Type Description
AddToDictionary void
AttachToVisualTree void
CoerceMaxDate object
CoerceVisibleMonth object
CreateVisibleDaysCollection ObservableCollection
DetachFromVisualTree void
FindFocusableDate DateTime?
GetCalendarDateByDate CalendarDate
GetFlag bool
GetKeyFromDataSourceItem DateTime?
IWeakEventListener bool
InvalidateVisibleDays void
InvokeDateSelectedChangedEvent void
IsFocusable bool
IsLeadingTrailingDay bool
IsValidDate bool
IsValidFirstDayOfWeek bool
IsValidMaxSelectionCount bool
IsValidNullableDate bool
MonthCalendar System
OnContainerLayoutUpdated void
OnContainerSelectionChanged void
OnDataSourceChanged void
OnDataSourceCollectionChanged void
OnDataSourceDatePathChanged void
OnDayContainerStyleChanged void
OnDayTemplateChanged void
OnDayTemplateSelectorChanged void
OnExecuteGotoCommand void
OnExecuteNextCommand void
OnExecutePreviousCommand void
OnFirstDayOfWeekChanged void
OnMaxDateChanged void
OnMaxMinDateChanged void
OnMaxSelectionCountChanged void
OnMinDateChanged void
OnNextButtonStyleChanged void
OnPreviousButtonStyleChanged void
OnQueryGotoCommand void
OnQueryNextCommand void
OnQueryPreviousCommand void
OnSelectedDateChanged void
OnSelectedDatesCollectionChanged void
OnVisibleMonthChanged void
RefreshDayTemplate void
RefreshNextButtonStyle void
RefreshPreviousButtonStyle void
RemoveFromDictionary void
RestoreSelection void
ScrollVisibleMonth void
SetFlag void
SetSelectionByRange void
TrimSelectedDates void
UpdateDataSource void
UpdateDataSourceToCalendarDates void

Public Methods

Method Description
GetContainerFromDate ( System.DateTime date ) : MonthCalendarItem

Return the UI element corresponding to the given date. Returns null if the date does not belong to the visible days or if no UI has been generated for it.

OnApplyTemplate ( ) : void

Called when the Template's tree has been generated

ToString ( ) : string

Returns a string representation for this control.

Protected Methods

Method Description
OnDateSelectionChanged ( DateSelectionChangedEventArgs e ) : void

Raise DateSelectionChanged event.

OnPreviewKeyDown ( System.Windows.Input.KeyEventArgs e ) : void

This is the method that responds to the PreviewKeyDown event.

Override OnPreviewKeyDown isn't recommended for Control Author, it's reserved for customer Because MonthCalenarContainer already handles the PageUp/PageDown/Home/End, we have to use Preview here.

OnVisibleMonthChanged ( RoutedPropertyChangedEventArgs e ) : void

Raise VisibleMonthChanged event.

Private Methods

Method Description
AddToDictionary ( object value ) : void

Add value to data source dictionary

AttachToVisualTree ( ) : void

Walk to visual tree to find the MonthCalendarContainer. Set the GroupFactory and GroupPanel. Register the selection change event if it is a Selector.

CoerceMaxDate ( DependencyObject d, object value ) : object
CoerceVisibleMonth ( DependencyObject d, object value ) : object
CreateVisibleDaysCollection ( System.DateTime firstDate, System.DateTime lastDate, DayOfWeek firstDayOfWeek ) : ObservableCollection

Generate the visible days collection based on the input firstdate, lastdate and firstdayofweek

DetachFromVisualTree ( ) : void

Clear our layout-specific data, and detach our current itemscontrol from monthcalendar

FindFocusableDate ( System.DateTime start, System.DateTime end, bool direction ) : DateTime?

GetCalendarDateByDate ( System.DateTime date ) : CalendarDate

Get the CalendarDate by date

GetFlag ( Flags flag ) : bool
GetKeyFromDataSourceItem ( object value ) : DateTime?

Get the DateTime value from the value with DataSourceDatePath/XPath the value works as a key for data source dictionary

IWeakEventListener ( Type managerType, object sender, EventArgs e ) : bool

Handle events from the centralized event table

InvalidateVisibleDays ( int scrollChange ) : void

Invalidate the visible days when switch month

InvokeDateSelectedChangedEvent ( List unselected, List selected ) : void

Raise the SelectionChanged event.

IsFocusable ( FrameworkElement fe ) : bool

True if the element can be focused

IsLeadingTrailingDay ( System.DateTime date ) : bool

True if the date is leading or traing day

IsValidDate ( object value ) : bool

Validate input value in MonthCalendar (MinDate, MaxDate, VisibleMonth)

IsValidFirstDayOfWeek ( object value ) : bool
IsValidMaxSelectionCount ( object o ) : bool
IsValidNullableDate ( object value ) : bool

Validate input value in MonthCalendar

MonthCalendar ( ) : System

Static Constructor

OnContainerLayoutUpdated ( object sender, EventArgs e ) : void

Update the SelectedDates to UI if those dates are added before UI ready

OnContainerSelectionChanged ( object sender, System.Windows.Controls.SelectionChangedEventArgs e ) : void

Update the selected dates status when user changes it by UI

OnDataSourceChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnDataSourceCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void

Update the CalendarDate.Data property when DataSource collection is changed

OnDataSourceDatePathChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnDayContainerStyleChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Called when DayContainerStyleProperty is invalidated on "d."

OnDayTemplateChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Called when DayTemplateProperty is invalidated on "d."

OnDayTemplateSelectorChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Called when DayTemplateSelectorProperty is invalidated on "d."

OnExecuteGotoCommand ( object target, System.Windows.Input.ExecutedRoutedEventArgs args ) : void
OnExecuteNextCommand ( object target, System.Windows.Input.ExecutedRoutedEventArgs args ) : void
OnExecutePreviousCommand ( object target, System.Windows.Input.ExecutedRoutedEventArgs args ) : void
OnFirstDayOfWeekChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnMaxDateChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnMaxMinDateChanged ( System.DateTime minDate, System.DateTime maxDate ) : void

Update the IsSelectable property of visible days and selected dates when max/min date has been changed

OnMaxSelectionCountChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnMinDateChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnNextButtonStyleChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnPreviousButtonStyleChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnQueryGotoCommand ( object target, System.Windows.Input.CanExecuteRoutedEventArgs args ) : void
OnQueryNextCommand ( object target, System.Windows.Input.CanExecuteRoutedEventArgs args ) : void
OnQueryPreviousCommand ( object target, System.Windows.Input.CanExecuteRoutedEventArgs args ) : void
OnSelectedDateChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
OnSelectedDatesCollectionChanged ( object sender, NotifyCollectionChangedEventArgs e ) : void

Handle SelectedDates collection changed event

OnVisibleMonthChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void
RefreshDayTemplate ( ) : void

Refresh the ItemTemplate/ItemTemplateSelector/ItemContainerStyle if DayTemplate/DayTemplateSelecotr/DayContainerStyle is set

RefreshNextButtonStyle ( ) : void
RefreshPreviousButtonStyle ( ) : void
RemoveFromDictionary ( object value ) : void

Remove value from data source dictionary

RestoreSelection ( int scrollChange ) : void

Restore the selection UI after switching month

ScrollVisibleMonth ( int direction, int delta ) : void

Scroll the current visible month of MothCalendar based on delta and direction

SetFlag ( Flags flag, bool set ) : void
SetSelectionByRange ( System.DateTime start, System.DateTime end ) : void

Select the dates between start and end. If one of them is null, only select the other one

TrimSelectedDates ( int limit ) : void

Delete redundant selected dates to fit the new MaxSelectionCount value

UpdateDataSource ( ) : void
UpdateDataSourceToCalendarDates ( ) : void

Update the data source data to the specific calendar dates

Method Details

GetContainerFromDate() public method

Return the UI element corresponding to the given date. Returns null if the date does not belong to the visible days or if no UI has been generated for it.
public GetContainerFromDate ( System.DateTime date ) : MonthCalendarItem
date System.DateTime
return MonthCalendarItem

OnApplyTemplate() public method

Called when the Template's tree has been generated
public OnApplyTemplate ( ) : void
return void

OnDateSelectionChanged() protected method

Raise DateSelectionChanged event.
protected OnDateSelectionChanged ( DateSelectionChangedEventArgs e ) : void
e DateSelectionChangedEventArgs
return void

OnPreviewKeyDown() protected method

This is the method that responds to the PreviewKeyDown event.
Override OnPreviewKeyDown isn't recommended for Control Author, it's reserved for customer Because MonthCalenarContainer already handles the PageUp/PageDown/Home/End, we have to use Preview here.
protected OnPreviewKeyDown ( System.Windows.Input.KeyEventArgs e ) : void
e System.Windows.Input.KeyEventArgs Event Arguments
return void

OnVisibleMonthChanged() protected method

Raise VisibleMonthChanged event.
protected OnVisibleMonthChanged ( RoutedPropertyChangedEventArgs e ) : void
e RoutedPropertyChangedEventArgs RoutedPropertyChangedEventArgs contains the old and new value.
return void

ToString() public method

Returns a string representation for this control.
public ToString ( ) : string
return string

Property Details

DataSourceDatePathProperty public_oe static_oe property

The DependencyProperty for the DataSourceDatePath property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DataSourceDatePathProperty
return System.Windows.DependencyProperty

DataSourceDateXPathProperty public_oe static_oe property

The DependencyProperty for the DataSourceDateXPath property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DataSourceDateXPathProperty
return System.Windows.DependencyProperty

DataSourceProperty public_oe static_oe property

The DependencyProperty for DataSource property
public static DependencyProperty,System.Windows DataSourceProperty
return System.Windows.DependencyProperty

DateSelectionChangedEvent public_oe static_oe property

An event fired when the selection changes
public static RoutedEvent,System.Windows DateSelectionChangedEvent
return System.Windows.RoutedEvent

DayContainerStyleProperty public_oe static_oe property

The DependencyProperty for the DayContainerStyle property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DayContainerStyleProperty
return System.Windows.DependencyProperty

DayContainerStyleSelectorProperty public_oe static_oe property

The DependencyProperty for the DayContainerStyleSelector property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DayContainerStyleSelectorProperty
return System.Windows.DependencyProperty

DayHeaderStyleProperty public_oe static_oe property

The DependencyProperty for the DayHeaderStyle property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DayHeaderStyleProperty
return System.Windows.DependencyProperty

DayTemplateProperty public_oe static_oe property

The DependencyProperty for the DayTemplate property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DayTemplateProperty
return System.Windows.DependencyProperty

DayTemplateSelectorProperty public_oe static_oe property

The DependencyProperty for the DayTemplateSelector property. Flags: none Default Value: null
public static DependencyProperty,System.Windows DayTemplateSelectorProperty
return System.Windows.DependencyProperty

FirstDayOfWeekProperty public_oe static_oe property

The DependencyProperty for FirstDayOfWeek property
public static DependencyProperty,System.Windows FirstDayOfWeekProperty
return System.Windows.DependencyProperty

MaxDateProperty public_oe static_oe property

The Property for the MaxDate property.
public static DependencyProperty,System.Windows MaxDateProperty
return System.Windows.DependencyProperty

MaxSelectionCountProperty public_oe static_oe property

The DependencyProperty for MaxSelectionCount property
public static DependencyProperty,System.Windows MaxSelectionCountProperty
return System.Windows.DependencyProperty

MinDateProperty public_oe static_oe property

The Property for the MinDate property.
public static DependencyProperty,System.Windows MinDateProperty
return System.Windows.DependencyProperty

NextButtonStyleProperty public_oe static_oe property

The DependencyProperty for the NextButtonStyle property. Flags: none Default Value: null
public static DependencyProperty,System.Windows NextButtonStyleProperty
return System.Windows.DependencyProperty

PreviousButtonStyleProperty public_oe static_oe property

The DependencyProperty for the PreviousButtonStyle property. Flags: none Default Value: null
public static DependencyProperty,System.Windows PreviousButtonStyleProperty
return System.Windows.DependencyProperty

SelectedDateProperty public_oe static_oe property

The DependencyProperty for SelectedDate property
public static DependencyProperty,System.Windows SelectedDateProperty
return System.Windows.DependencyProperty

ShowsDayHeadersProperty public_oe static_oe property

The DependencyProperty for ShowsDayHeaders property
public static DependencyProperty,System.Windows ShowsDayHeadersProperty
return System.Windows.DependencyProperty

ShowsTitleProperty public_oe static_oe property

The DependencyProperty for ShowsTitle property
public static DependencyProperty,System.Windows ShowsTitleProperty
return System.Windows.DependencyProperty

ShowsWeekNumbersProperty public_oe static_oe property

The DependencyProperty for ShowsWeekNumbers property
public static DependencyProperty,System.Windows ShowsWeekNumbersProperty
return System.Windows.DependencyProperty

TitleStyleProperty public_oe static_oe property

The DependencyProperty for the TitleStyle property. Flags: none Default Value: null
public static DependencyProperty,System.Windows TitleStyleProperty
return System.Windows.DependencyProperty

VisibleMonthChangedEvent public_oe static_oe property

An event fired when the display month switches
public static RoutedEvent,System.Windows VisibleMonthChangedEvent
return System.Windows.RoutedEvent

VisibleMonthProperty public_oe static_oe property

The DependencyProperty for VisibleMonth property
public static DependencyProperty,System.Windows VisibleMonthProperty
return System.Windows.DependencyProperty

WeekNumberStyleProperty public_oe static_oe property

The DependencyProperty for the WeekNumberStyle property. Flags: none Default Value: null
public static DependencyProperty,System.Windows WeekNumberStyleProperty
return System.Windows.DependencyProperty