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
  4. ToolStrip

ToolStripButton

Description

This component represents a toolbar button in Blazor using the Gap.Blazor.ToolStripButton model. It is rendered inside a Telerik ToolBarButton and supports displaying an image, text, or both. The component also supports tooltips, autosizing, and click interaction.

Usage

<WMStyleBase model=@toolStripButton></WMStyleBase>

<ToolBarButton Class="@($"{toolStripButton.GetStringClasses()} {toolStripButton.GetToolTipClass()} {GetAutoSizeClass()}")"
               Title="@toolStripButton.GetToolTipText()"
               OnClick="@toolStripItemClick"
               Visible="this.Visible">
    @if (this.ShowImage && this.GetImage() is string image)
    {
        <div>
            <img class="icon-size-default" src="@image" />
        </div>
    }
    @if (this.ShowText && !string.IsNullOrEmpty(this.Text))
    {
        <div>
            <p class="button-text-default">@toolStripButton.Text</p>
        </div>
    }
</ToolBarButton>

<style>
    .@model.GetComponentClass() {
        position: relative;
        display: block;
        padding: 2px;
    }

    .@(model.GetComponentClass() + ".AutoSize") {
        width: auto;
        height: auto;
    }

    .@model.GetComponentClass() .icon-size-default {
        display: block;
        margin-inline: auto;
        float: @this.toolStripButton.ImageAlign.GetFloatStyle();
    }

    .@model.GetComponentClass() .button-text-default {
        margin: 1px;
        clear: both;
        float: @this.toolStripButton.TextAlign.GetFloatStyle();
    }
</style>

Properties

  • toolStripButton: Instance of the Gap.Blazor.ToolStripButton model.

  • DisplayStyle: Determines whether to show image, text, or both (Image, Text, ImageAndText).

  • ToolTipText: Tooltip shown on hover.

  • Image: The image displayed on the button.

  • Text: The label text displayed on the button.

  • ImageAlign / TextAlign: Control the float alignment of the image and text.

Methods

  • OnInitialized(): Subscribes to NotifyModelChanged and ImageChanged to update the UI when the model changes.

  • toolStripItemClick(MouseEventArgs): Invokes the PerformClick() method on the model when the button is clicked.

  • GetImage(): Retrieves the image source from the model.

  • ShowImage / ShowText: Boolean flags derived from DisplayStyle to control rendering.

Dynamic Rendering

  • ToolBarButton: Renders the button UI.

  • Image and Text: Conditionally rendered based on DisplayStyle.

  • CSS Styling: Dynamically applies layout and alignment styles.

Styles

.@model.GetComponentClass() {
    position: relative;
    display: block;
    padding: 2px;
}

.@model.GetComponentClass().AutoSize {
    width: auto;
    height: auto;
}

.@model.GetComponentClass() .icon-size-default {
    display: block;
    margin-inline: auto;
    float: [based on ImageAlign];
}

.@model.GetComponentClass() .button-text-default {
    margin: 1px;
    clear: both;
    float: [based on TextAlign];
}

Events

  • Click: Triggered when the button is clicked.

  • ImageChanged: Updates the UI when the image changes.

  • NotifyModelChanged: Triggers a full UI refresh when the model changes.

PreviousToolStripNextToolStripLabel

Last updated 2 days ago