Back to Devexpress

DxToolbarDataMappingBase.Checked Property

blazor-devexpress-dot-blazor-dot-base-dot-dxtoolbardatamappingbase-80901adc.md

latest3.2 KB
Original Source

DxToolbarDataMappingBase.Checked Property

Specifies whether an item is checked. Map this field to a data source field.

Namespace : DevExpress.Blazor.Base

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[DefaultValue(null)]
[Parameter]
public string Checked { get; set; }

Property Value

TypeDefaultDescription
Stringnull

The data source field.

|

Remarks

The following code snippet binds the Toolbar to the collection of FormatItem objects. Each object can have child objects. The code specifies the Children, Text, and Checked mappings to adjust the Toolbar’s data model to the specified data source.

razor
<div class="card p-2">
    <DxToolbar [email protected] ItemClick=@OnItemClicked>
        <DataMappings>
            <DxToolbarDataMapping Name="ValueName" Text="ValueName" Children="Values" Checked="IsChecked" />
            <DxToolbarDataMapping Text="Value" Level="1" />
        </DataMappings>
    </DxToolbar>
</div>

@code {
    void OnItemClicked(ToolbarItemClickEventArgs args) {
        if (args.ItemName == "Align") {
            ((FormatItem)args.Info.Data).ChangeChecked();
        }
    }
}
csharp
public class FormatItem {
    public string? ValueName { get; set; }
    public List<FormatSubItem> Values { get; } = new List<FormatSubItem>();
    public bool IsChecked { get; set; }
    public void ChangeChecked() {
        IsChecked = !IsChecked;
    }
    public static IEnumerable<FormatItem> ToolbarItems = new List<FormatItem>() {
        new FormatItem() { ValueName = "Font", Values = {
                new FormatSubItem { Value = "Times New Roman" },
                new FormatSubItem { Value = "Tahoma" },
                new FormatSubItem { Value = "Verdana" }
            }
        },
        new FormatItem() { ValueName = "Size", Values = {
                new FormatSubItem { Value = "8px" },
                new FormatSubItem { Value = "10px" },
                new FormatSubItem { Value = "12px" }
            }
        },
        new FormatItem() {
            ValueName = "Align",
            IsChecked = true
        }
    };
}

public class FormatSubItem { 
    public string? Value; 
}

Refer to the DxToolbarDataMappingBase class description for additional information and examples.

See Also

DxToolbarDataMappingBase Class

DxToolbarDataMappingBase Members

DevExpress.Blazor.Base Namespace