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

CheckedListBox

Description

This component represents a checked list box in Blazor using the Gap.Blazor.CheckedListBox model. It leverages the Telerik ListBox component to display a list of items with checkboxes, supporting dynamic selection, item checking, and model synchronization.

Usage

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

<WMStyleBase model=@CheckedListBoxModel></WMStyleBase>
<TelerikListBox @ref="@CheckedListBoxRef"
    Data="@CheckedListBoxModel.ListControlItems"
    SelectionMode="@GetSelectionMode()"
    SelectedItemsChanged="SelectedIndexChangeCallback"
    Height="@CheckedListBoxModel.Height.ToString()"
    Width="@CheckedListBoxModel.Width.ToString()"
    class="@CheckedListBoxModel.GetStringClasses()">
        <ListBoxToolBarSettings>
            <ListBoxToolBar Visible="true" />
        </ListBoxToolBarSettings>
        <ItemTemplate>
            @if (context != null)
            {
                var item = (ListControlItem)context;
                var checkboxValue = (bool?)item.Value;

                <TelerikCheckBox Id="@item.GetHashCode().ToString()" Value="@checkboxValue" ValueChanged="@( (bool? value) => OnCheckBoxValueChanged(value, item) )"/>
                <label for="@item.GetHashCode().ToString()">@item.Text</label>
            }
        </ItemTemplate>
</TelerikListBox>

Properties

  • CheckedListBoxModel: Instance of the Gap.Blazor.CheckedListBox model.

  • CheckedListBoxRef: Reference to the Telerik ListBox component.

Methods

  • OnInitialized(): Subscribes to various model events to keep the UI in sync with the backend.

  • SyncModelChanges(): Updates the UI based on model changes and rebinds the list box.

  • OnCheckBoxValueChanged(bool?, ListControlItem): Updates the check state of an item in the model.

  • GetSelectionMode(): Maps the model's SelectionMode to Telerik's ListBoxSelectionMode.

  • SelectedIndexChange(IEnumerable): Handles selection changes and updates the model accordingly.

Dynamic Rendering

The component dynamically renders a list of checkable items based on the CheckedListBox model:

  • WMStyleBase: Applies styles based on the model.

  • TelerikListBox: Displays the list of items.

  • TelerikCheckBox: Renders a checkbox for each item.

  • Label: Displays the text for each item.

Styles

  • Height/Width: Set dynamically from the model.

  • CSS Classes: Applied using CheckedListBoxModel.GetStringClasses().

Events

  • Items Collection Events: AfterAdd, AfterAddRange, AfterClear, AfterInsert, AfterRemoveAt

  • Selection Events: SelectedIndexChanged, SelectedIndicesChanged, SelectionModeChanged

  • ItemCheck: Triggered when an item’s check state changes.

  • NotifyModelChanged: General event to trigger UI updates.

PreviousCheckBoxNextComboBox

Last updated 2 days ago