WebMap for Blazor
  • WebMap Blazor
    • Modernization
      • Overview
      • Modernization Challenges
      • Our solution
      • What is Blazor?
      • How does Blazor Work?
      • Windows Forms in Blazor
      • Deployment
      • Interfacing with hardware devices
    • Research for Blazor
      • Handling Reference Parameters in Async Methods with Ref<T>
      • Alternatives to Async Properties in C#
      • Issue with using "MessageBox.Show" in Blazor
      • File Upload Functionality
      • Async/Await Feature for WebMap Blazor
    • Assessment Tool
    • Conversion Tool
      • Getting Started
      • Modals and Dialogs
      • Static Service Management
      • ImageListStreamer
      • Solution and Project Structure
        • Solution Generator
    • DCP: Desktop Compatibility Library
      • API Documentation
        • Blazor DCP: Gap.Blazor.Application Class Reference
      • Components Information
        • Button Component
        • Application Data Component
        • GroupBox Component
        • Label Component
        • CheckBox
        • CheckedListBox
        • ComboBox
        • DateTimePicker
        • Form
        • ListBox
        • ListView
          • WMListViewDetails
        • Mdi Container Component
        • MenuStrip
        • MessageBox
        • MonthCalendar
        • Panel
        • PictureBox
        • ProgressBar
        • RadioButton
        • StatusStrip
        • ToolStripStatusLabel
        • TabControl
        • TabPage
        • TextBox
        • ToolStrip
          • ToolStripButton
          • ToolStripLabel
          • ToolStripSeparator
        • ToolTip
    • Post Conversion
      • How To?
        • Create a new WebMap Window?
        • Create a new WebMap Component?
        • Create a native Blazor Window in a WebMap app?
        • Create a native Blazor Component in a WebMap Window?
        • Change the default WebMap visual layout?
    • WebMap: Angular vs Blazor
      • Footprint
      • Binaries size
      • Chatiness
      • Performance
      • Extensibility
      • Maintainability
      • Debugging
      • Project Structure
    • WebMap for Blazor Release Notes
      • Beta version
    • FAQ
    • Errors and Troubleshooting
    • License
Powered by GitBook
On this page
  • Description
  • Usage
  • Properties
  • Methods
  • Dynamic Rendering
  • Styles
  • Events
Export as PDF
  1. WebMap Blazor
  2. DCP: Desktop Compatibility Library
  3. Components Information

DateTimePicker

Description

This component represents a date and time picker in Blazor using the Gap.Blazor.DateTimePicker model. It integrates with Telerik’s DatePicker and optionally includes a checkbox to enable or disable the date selection. The component supports dynamic formatting and styling based on the model.

Usage

@using Gap.Blazor
@using Gap.Blazor.Components
@using Telerik.Blazor.Components
@inherits WMControlComponentBase
@namespace Gap.Blazor.Components

<WMStyleBase model=@dateTimePicker></WMStyleBase>
<div class="@dateTimePicker.GetStringClasses()">
    @if(dateTimePicker.ShowCheckBox == true)
    {
        <TelerikCheckBox @bind-Value="@dateTimePicker.Checked"></TelerikCheckBox>
    }
    <TelerikDatePicker class="@(!dateTimePicker.Checked ? "k-unchecked" : "" )"
                       @bind-Value="@dateTimePicker.Value" 
                       Format="@convertToTelerikFormat()" 
                       OnChange=@dateTimePickerOnChange 
                       OnOpen="@updateCheckedValue">
    </TelerikDatePicker>
</div>

<style>
    .@model.GetComponentClass() {
        display: inline-flex;
    }
    .@model.GetComponentClass() .k-checkbox-wrap {
        margin-top: 5px;
    }
    .@model.GetComponentClass() .k-input-inner {
        font-size: @dateTimePicker.Font.GetFontSize();
    }
    .@model.GetComponentClass() .k-input-button {
        width: 20px;
    }
    .k-datetimepicker.k-unchecked .k-input-inner {
        pointer-events: none;
        opacity: 0.6;
        filter: grayscale(0.1);
    }
</style>

Properties

  • DateTimePicker: Instance of the Gap.Blazor.DateTimePicker model.

  • Value: Bound to the selected date/time value.

  • Checked: Boolean indicating whether the date picker is enabled (used with ShowCheckBox).

  • Format: Determines the display format of the date/time.

Methods

  • OnInitialized(): Subscribes to the ValueChanged event to trigger UI updates.

  • DateTimePickerOnChange(): Invokes the model’s PerformValueChange() method.

  • UpdateCheckedValue(): Automatically sets Checked = true when the calendar is opened.

  • ConvertToTelerikFormat(): Converts the model’s format to a Telerik-compatible string:

    • Long → "dddd, MMMM dd, yyyy"

    • Short → "M/d/yyyy"

    • Time → "h:mm tt"

    • Custom → Uses CustomFormat from the model

Dynamic Rendering

The component dynamically renders a date picker with optional checkbox based on the DateTimePicker model:

  • WMStyleBase: Applies styles based on the model.

  • TelerikCheckBox: Toggles the enabled state of the date picker.

  • TelerikDatePicker: Displays the date/time selection UI.

Styles

  • Layout: Uses inline-flex for alignment.

  • Checkbox: Margins adjusted for visual alignment.

  • Input Styling: Font size and button width are model-driven.

  • Disabled State: When unchecked, the date picker is visually disabled using opacity and pointer restrictions.

Events

  • ValueChanged: Triggered when the selected date/time changes.

PreviousComboBoxNextForm

Last updated 2 days ago