DOT

VVM

 DOCS

Version: 1.0 | 1.1 |

RangeCalendar

in namespace DotVVM.BusinessPack.Controls

Renders a calendar which lets the user to select the begin and end date.

Properties

Name Type Description Notes Default Value
Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
Static
DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
attribute
inner element
static value
bindable
default
DisplayMode CalendarDisplayMode Gets or Sets Display mode of calendar.
attribute
inner element
static value
bindable
default
Standard
Enabled Boolean Gets or sets whether the control is enabled.
attribute
inner element
static value
bindable
default
True
ExcludedDays ICollection<ExcludedDay>
attribute
inner element
static value
bindable
default
ExcludedRanges ICollection<ExcludedRange>
attribute
inner element
static value
bindable
default
ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
MaxDate DateTime? Gets or sets the highest selectable date.
attribute
inner element
static value
bindable
default
MinDate DateTime? Gets or sets the lowest selectable date.
attribute
inner element
static value
bindable
default
Mode DateTimePickerType? Gets or sets whether you want the user to pick only date, only time, or both date and time.
attribute
inner element
static value
bindable
default
DateTime
SelectedEndDate DateTime? Gets or sets the end date of the date range.
attribute
inner element
static value
bindable
default
SelectedStartDate DateTime? Gets or sets the start date of the date range.
attribute
inner element
static value
bindable
default
Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
SelectionCompleted Command Gets or sets the command that is called when the user successfully selects or unselects a value.

Usage & Scenarios

Renders a Gregorian-style calendar control which lets the user to select two date, time or date and time values.

HTML Rendered by the Control

Sample 1: Basic Usage

The SelectedStartDate and SelectedEndDate properties represent DateTime values with the date range selected in the control.

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}" />

<p>Selected dates: <dot:Literal Text="{value: StartDate}" FormatString="g" /> - <dot:Literal Text="{value: EndDate}" FormatString="g" /></p>
using System;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RangeCalendar.sample1
{
    public class ViewModel
    {
        public DateTime StartDate { get; set; } = DateTime.Now.AddDays(-1);
        public DateTime EndDate { get; set; } = DateTime.Now.AddDays(1);
    }
}

Sample 2: Selection Bounds

You can use the MinDate and MaxDate properties to specify the minimum and maximum values for the selection.

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}"
                  MinDate="{value: MinimumDate}"
                  MaxDate="{value: MaximumDate}" />

<p>Selected dates: <dot:Literal Text="{value: StartDate}" FormatString="g" /> - <dot:Literal Text="{value: EndDate}" FormatString="g" /></p>
using System;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RangeCalendar.sample2
{
    public class ViewModel
    {
        public DateTime StartDate { get; set; } = DateTime.Now.AddDays(-1);
        public DateTime EndDate { get; set; } = DateTime.Now.AddDays(1);
        public DateTime MinimumDate { get; set; } = DateTime.Now.AddDays(-5);
        public DateTime MaximumDate { get; set; } = DateTime.Now.AddDays(5);
    }
}

Sample 3: Modes

You can use the Mode property to determine whether you want to select Date, Time or DateTime (a combination of date and time).

Even if you are in the Time mode, the control still requires the SelectedStartDate and SelectedEndDate properties to be bound to properties of DateTime type.

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}"
                  Mode="Date" />

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}"
                  Mode="Time" />

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}"
                  Mode="DateTime" />
using System;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RangeCalendar.sample3
{
    public class ViewModel
    {
        public DateTime StartDate { get; set; } = DateTime.Now.AddDays(-1);
        public DateTime EndDate { get; set; } = DateTime.Now.AddDays(1);
    }
}

Sample 4: Extended Mode

If you need select both date and time, you can set the DisplayMode property to the Extended mode which will display the time selection area below the calendar.

This mode is allowed only when the Mode property is DateTime.

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}"
                  DisplayMode="Extended" />

<p>Selected dates: <dot:Literal Text="{value: StartDate}" FormatString="g" /> - <dot:Literal Text="{value: EndDate}" FormatString="g" /></p>
using System;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RangeCalendar.sample4
{
    public class ViewModel
    {
        public DateTime StartDate { get; set; } = DateTime.Now.AddDays(-1);
        public DateTime EndDate { get; set; } = DateTime.Now.AddDays(1);
    }
}

Sample 5: Format Strings

The FormatString property specifies the format that will be used to display selected dates. Use standard or custom .NET date format strings.

The language of the calendar and the first day of week is specified by the request culture. You can find more info in the Globalization tutorial.

<bp:RangeCalendar SelectedStartDate="{value: StartDate}"
                  SelectedEndDate="{value: EndDate}"
                  SelectionCompleted="{command: SelectionCompleted()}" />

<p>Date range selection has changed {{value: DateSelectionsCount}} times.</p>
using System;

namespace DotvvmWeb.Views.Docs.Controls.businesspack.RangeCalendar.sample5
{
    public class ViewModel
    {
        public DateTime StartDate { get; set; } = DateTime.Now.AddDays(-1);
        public DateTime EndDate { get; set; } = DateTime.Now.AddDays(1);
        public int DateSelectionsCount { get; set; }

        public void SelectionCompleted()
        {
            DateSelectionsCount++;
        }
    }
}

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message