Class DateTimeSpinnerBase
Represents a SpinnerView control that has date and time fields as its columns.
Implements
Inherited Members
Namespace: Syncfusion.UI.Xaml.Editors
Assembly: Syncfusion.Editors.WinUI.dll
Syntax
public class DateTimeSpinnerBase : SpinnerView, IDisposable
Examples
The below examples shows, how to initialize the DateTimeSpinnerBase control.
<syncfusion:DateTimeSpinnerBase />
Constructors
DateTimeSpinnerBase()
Initializes a new instance of the DateTimeSpinnerBase class.
Declaration
public DateTimeSpinnerBase()
Fields
BlackoutDatesProperty
Identifies BlackoutDates dependency property.
Declaration
public static readonly DependencyProperty BlackoutDatesProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the BlackoutDates dependency property. |
CalendarIdentifierProperty
Identifies CalendarIdentifier dependency property.
Declaration
public static readonly DependencyProperty CalendarIdentifierProperty
Field Value
Type |
---|
Microsoft.UI.Xaml.DependencyProperty |
DisplayDateTimeFormatProperty
Identifies DisplayDateTimeFormat dependency property.
Declaration
public static readonly DependencyProperty DisplayDateTimeFormatProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the DisplayDateTimeFormat dependency property. |
ItemContainerStyleProperty
Identifies ItemContainerStyle dependency property.
Declaration
public static readonly DependencyProperty ItemContainerStyleProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the ItemContainerStyle dependency property. |
ItemTemplateProperty
Identifies ItemTemplate dependency property.
Declaration
public static readonly DependencyProperty ItemTemplateProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the ItemTemplate dependency property. |
ItemTemplateSelectorProperty
Identifies ItemTemplateSelector dependency property.
Declaration
public static readonly DependencyProperty ItemTemplateSelectorProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the ItemTemplateSelector dependency property. |
MaxDateTimeProperty
Identifies MaxDateTime dependency property.
Declaration
public static readonly DependencyProperty MaxDateTimeProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the MaxDateTime dependency property. |
MinDateTimeProperty
Identifies MinDateTime dependency property.
Declaration
public static readonly DependencyProperty MinDateTimeProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the MinDateTime dependency property. |
SelectedDateTimeProperty
Identifies SelectedDateTime dependency property.
Declaration
public static readonly DependencyProperty SelectedDateTimeProperty
Field Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DependencyProperty | The identifier for the SelectedDateTime dependency property. |
Properties
BlackoutDates
Gets or sets the collection of restricted dates and times, that is not allowed to select.
Declaration
public DateTimeOffsetCollection BlackoutDates { get; set; }
Property Value
Type | Description |
---|---|
DateTimeOffsetCollection | The default value is null. |
Remarks
Disable the date in DateTimeSpinnerBase if the SelectedDateTime value is present in BlackoutDates. System.InvalidOperationException will be thrown when a BlackoutDate is selected.
Examples
The following example shows how to add date in BlackoutDates
collections.
<Grid>
<syncfusion:DateTimeSpinnerBase x:Name="DateTimeSpinnerBase" />
</Grid>
public MainPage()
{
this.InitializeComponent();
DateTimeSpinnerBase.BlackoutDates = new Syncfusion.UI.Xaml.Editors.DateTimeOffsetCollection();
DateTimeSpinnerBase.BlackoutDates.Add(DateTimeOffset.Now.AddDays(-7));
}
CalendarIdentifier
Gets or sets the calendar system to use.
Declaration
public string CalendarIdentifier { get; set; }
Property Value
Type | Description |
---|---|
System.String | The default calendar is System.Globalization.GregorianCalendar. |
Remarks
Set the CalendarIdentifier property to specify the calendar system used by the DateTimeSpinnerBase. The DateTimeSpinnerBase supports all calendar systems in the CalendarIdentifiers class except System.Globalization.JapaneseCalendar and Lunar type calendars.
Examples
The following example shows how to set the CalendarIdentifier in DateTimeSpinnerBase.
<Grid>
<syncfusion:DateTimeSpinnerBase x:Name="julianDatePicker" CalendarIdentifier="JulianCalendar"/>
</Grid>
public MainPage()
{
this.InitializeComponent();
julianDatePicker.CalendarIdentifier = Windows.Globalization.CalendarIdentifiers.Julian;
}
DisplayDateTimeFormat
Gets or sets the System.DateTime format used to format the DateTimeSpinnerBase value for display purposes.
Declaration
public string DisplayDateTimeFormat { get; set; }
Property Value
Type | Description |
---|---|
System.String | The default value is "{}{month.abbreviated}{day.integer}{year.full}". |
ItemContainerStyle
Gets or sets the Microsoft.UI.Xaml.Style that is applied to the SpinnerItem generated for each item in SpinnerColumnView.
Declaration
public Style ItemContainerStyle { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.Style | The default value is null. |
Examples
The following example shows how to define a ItemContainerStyle
for the DateTimeSpinnerBase control.
<Page.Resources>
<Style x:Key="ItemContainerStyle" TargetType="syncfusion:SpinnerItem">
<Setter Property="FontStyle" Value="Oblique" />
</Style>
</Page.Resources>
<Grid>
<syncfusion:DateTimeSpinnerBase
x:Name="DateTimeSpinnerBase"
ItemContainerStyle="{StaticResource ItemContainerStyle}" />
</Grid>
ItemTemplate
Gets or sets the DataTemplate
that defines the visual representation of the drop-down item.
Declaration
public DataTemplate ItemTemplate { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.DataTemplate | The default value is null. |
Remarks
The DateTimeFieldItemInfo is the data context of this DataTemplate
.
Examples
The following example shows how to define a ItemTemplate
for the DateTimeSpinnerBase control.
<Page.Resources>
<DataTemplate x:Name="ItemTemplate">
<Grid
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="pink">
<TextBlock
Foreground="Red"
Text="{Binding DisplayText}" />
</Grid>
</DataTemplate>
</Page.Resources>
<Grid>
<syncfusion:DateTimeSpinnerBase
x:Name="dateTimeSpinnerBase"
ItemTemplate="{StaticResource ItemTemplate}" />
</Grid>
ItemTemplateSelector
Gets or sets the custom logic for choosing a template used to display each item.
Declaration
public DataTemplateSelector ItemTemplateSelector { get; set; }
Property Value
Type | Description |
---|---|
Microsoft.UI.Xaml.Controls.DataTemplateSelector | The default is null. |
Examples
The following example shows how to define a ItemTemplateSelector
for the DateTimeSpinnerBase control.
<Application.Resources>
<DataTemplate x:Name="SelectorItemTemplate1">
<Grid Background="Pink">
<TextBlock Text="{Binding DisplayText}" Foreground="Yellow" />
</Grid>
</DataTemplate>
<DataTemplate x:Name="SelectorItemTemplate2">
<Grid Background="Orange">
<TextBlock Text="{Binding DisplayText}" Foreground="Red" />
</Grid>
</DataTemplate>
</Application.Resources>
<Page.Resources>
<local:DayTemplateSelector x:Key="dayTemplateSelector" />
</Page.Resources>
<Grid>
<syncfusion:DateTimeSpinnerBase
x:Name="datepicker"
ItemTemplateSelector="{StaticResource dayTemplateSelector}" />
</Grid>
public MainPage()
{
this.InitializeComponent();
ObservableCollection<string> dayCollection = new ObservableCollection<string>();
for (int i = 1; i <= 31; i++)
{
dayCollection.Add(i.ToString());
}
dayColumn.ItemsSource = dayCollection;
}
public class DayTemplateSelector : DataTemplateSelector
{
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{
if (item != null)
{
DateTimeFieldItemInfo dateTimeField = item as DateTimeFieldItemInfo;
if (dateTimeField.Field == DateTimeField.Day)
{
if (int.Parse(dateTimeField.DisplayText) < 15)
return Application.Current.Resources["SelectorItemTemplate1"] as DataTemplate;
else
return Application.Current.Resources["SelectorItemTemplate2"] as DataTemplate;
}
}
return base.SelectTemplateCore(item, container);
}
}
MaxDateTime
Gets or sets the maximum number of dates to be listed in the DateTimeSpinnerBase control.
Declaration
public DateTimeOffset MaxDateTime { get; set; }
Property Value
Type | Description |
---|---|
System.DateTimeOffset | The maximum number of dates to be listed in the DateTimeSpinnerBase. |
MinDateTime
Gets or sets the minimum number of dates to be listed in the DateTimeSpinnerBase control.
Declaration
public DateTimeOffset MinDateTime { get; set; }
Property Value
Type | Description |
---|---|
System.DateTimeOffset | The minimum number of dates to be listed in the DateTimeSpinnerBase. |
SelectedDateTime
Gets or sets the currently selected date for DateTimeSpinnerBase.
Declaration
public Nullable<DateTimeOffset> SelectedDateTime { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTimeOffset> | The default value is System.DateTimeOffset.Now. |
Methods
Dispose(Boolean)
Release the unmanaged resources of SpinnerView.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Used to indicate perform dispose or not. |
Overrides
InvalidateFields(DateTimeField)
Helps to invalidate specific date time field in DateTimeSpinnerBase.
Declaration
public void InvalidateFields(DateTimeField field)
Parameters
Type | Name | Description |
---|---|---|
DateTimeField | field | The date time field. |
ItemPrepared(Int32, ISpinnerItemInfo, SpinnerItem)
Invoked each time an element is made ready for use.
Declaration
public override void ItemPrepared(int index, ISpinnerItemInfo spinnerItemInfo, SpinnerItem element)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The column index. |
ISpinnerItemInfo | spinnerItemInfo | The spinner item info. |
SpinnerItem | element | The spinner item. |
Overrides
Remarks
This method is invoked for both a newly created element as well as an element that already exists and is being re-used from the recycle queue.
OnApplyTemplate()
Declaration
protected override void OnApplyTemplate()
Overrides
OnCreateAutomationPeer()
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type |
---|
Microsoft.UI.Xaml.Automation.Peers.AutomationPeer |
Overrides
OnSelectionChanged(SpinnerItemSelectionChangedEventArgs)
Invoked when the selection is changed in SpinnerColumnView.
Declaration
public override void OnSelectionChanged(SpinnerItemSelectionChangedEventArgs eventArgs)
Parameters
Type | Name | Description |
---|---|---|
SpinnerItemSelectionChangedEventArgs | eventArgs | Contains details regarding old and new selected index value. |
Overrides
Remarks
This method occurs whenever there is a change to a selection. A selection can be changed programmatically or by user interaction like scrolling, key navigation.
Events
DateTimeFieldItemPrepared
Occurs when a SpinnerItem is loading, for each items in date or time field.
Declaration
public event EventHandler<DateTimeFieldItemPreparedEventArgs> DateTimeFieldItemPrepared
Event Type
Type |
---|
System.EventHandler<DateTimeFieldItemPreparedEventArgs> |
Remarks
Content and appearance of items in drop-down can be customized using this event.
DateTimeFieldPrepared
Occurs when a field of date or time is loading.
Declaration
public event EventHandler<DateTimeFieldPreparedEventArgs> DateTimeFieldPrepared
Event Type
Type |
---|
System.EventHandler<DateTimeFieldPreparedEventArgs> |
SelectedDateTimeChanged
Occurs when the SelectedDateTime value is changed.
Declaration
public event EventHandler<SelectedDateTimeChangedEventArgs> SelectedDateTimeChanged
Event Type
Type |
---|
System.EventHandler<SelectedDateTimeChangedEventArgs> |