Click or drag to resize

DateTimeSource Class

Provides values for date and time suitable for bindings.
Inheritance Hierarchy

Namespace:  TomsToolbox.Wpf
Assembly:  TomsToolbox.Wpf (in TomsToolbox.Wpf.dll) Version: 1.0.74.0
Syntax
public class DateTimeSource : ObservableObject

The DateTimeSource type exposes the following members.

Constructors
  NameDescription
Public methodDateTimeSource
Initializes a new instance of the DateTimeSource class.
Top
Properties
  NameDescription
Public propertyDispatcher
Gets the dispatcher of the thread where this object was created.

[NotNull]

(Inherited from ObservableObject.)
Public propertyNow
Gets a DateTime object that is set to the current date and time on this computer, expressed as the local time.
Public propertyToday
Gets the current date.
Public propertyUpdateInterval
Gets or sets the interval in which the PropertyChanged event is raised for all properties.
Public propertyUtcNow
Gets a DateTime object that is set to the current date and time on this computer, expressed as the Coordinated Universal Time (UTC).
Top
Methods
  NameDescription
Protected methodDetachEventSource
Detaches the event source.
(Inherited from ObservableObjectBase.)
Protected methodDetachEventSources
Detaches all event sources.
(Inherited from ObservableObjectBase.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from ObservableObjectBase.)
Protected methodGetDataErrors
Gets the validation errors for a specified property or for the entire entity.

[NotNull, ItemNotNull]

(Inherited from ObservableObjectBase.)
Protected methodOnDataErrorsEvaluated
Called when data errors have been evaluated. Used e.g. to track data errors for each property.
(Inherited from ObservableObjectBase.)
Protected methodOnPropertyChanged(String)
Raises the PropertyChanged event for the property with the specified name.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Protected methodOnPropertyChangedT(ExpressionFuncT)
Raises the PropertyChanged event for the property identified by the specified property expression.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Protected methodRelayEventsOf(INotifyPropertyChanged)
Relays the property changed events of the source object. The properties to relay must be declared with the RelayedEventAttribute.
(Inherited from ObservableObjectBase.)
Protected methodRelayEventsOf(INotifyPropertyChanged, INotifyPropertyChanged)
Relays the property changed events of the source object (if not null) and detaches the old source (if not null).
(Inherited from ObservableObjectBase.)
Protected methodSetPropertyT(T, T, ExpressionFuncT)
Sets the property and raises the PropertyChanged event for the property identified by the specified property expression.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Protected methodSetPropertyT(T, T, String)
Sets the property and raises the PropertyChanged event for the property identified by the specified property expression.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Protected methodSetPropertyT(T, T, ActionT, T, String)
Sets the property and raises the PropertyChanged event for the property identified by the specified property expression.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Protected methodSetPropertyT(T, T, ExpressionFuncT, ActionT, T)
Sets the property and raises the PropertyChanged event for the property identified by the specified property expression.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Protected methodSetPropertyT(T, T, String, ActionT, T)
Sets the property and raises the PropertyChanged event for the property identified by the specified property expression.

[NotifyPropertyChangedInvocator]

(Inherited from ObservableObjectBase.)
Top
Events
  NameDescription
Public eventPropertyChanged
Occurs when a property value changes.
(Inherited from ObservableObjectBase.)
Top
Fields
  NameDescription
Public fieldStatic memberDefault
The default singleton object. Use this as a source for binding that supports manual updating.

[NotNull]

Top
Extension Methods
  NameDescription
Public Extension MethodSafeCastT
Performs a cast from object to T, avoiding possible null violations if T is a value type.

[CanBeNull]

(Defined by ObjectExtensions.)
Top
Remarks
This expression in XAML would be static, since the Source is never updated and would always have it's initial value, UpdateTarget won't have any effect.

MyDayOfWeek="{Binding Path=DayOfWeek, Source={x:Static system:DateTime.Today}}"

Using DateTimeSource instead, UpdateTarget will work, and MyDayOfWeek will be updated with the actual value:

MyDayOfWeek="{Binding Path=Today.DayOfWeek, Source={x:Static toms:DateTimeSource.Default}}"

See Also