TagInfo<T> Class

Provides information about a tag.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.dll

Declaration

public class TagInfo<T>

Type Parameters

Name Description
T

The data item type.

Remarks

Use the TagInfo instances to define tags to be customized via templates (TagTemplate).

The code below demonstrates how to customize a tag appearance according to its type and text.

<DxTagBox Data="@DataSource"
          TextFieldName ="Data"
          AllowCustomTags ="true"
          @bind-Tags="@Tags">
            <TagTemplate Context="tagInfo">
                @{
                    string tagClass = tagInfo.IsCustom ? "btn btn-outline-secondary" : "btn " + tagInfo.DataItem.CssClass;
                    <span class=@tagClass>
                        <span>@tagInfo.Text</span>
                        <span @onclick="@tagInfo.RemoveTagAction">&times;</span>
                    </span>
                }
            </TagTemplate>
</DxTagBox>

@code {
    Option[] DataSource = null;

    IEnumerable<string> tags;
    IEnumerable<string> Tags { get => tags; set { tags = value; InvokeAsync(StateHasChanged); } }

    protected override void OnInitialized() {
        DataSource = new Option[] {
            new Option("Option 1", "btn-primary"),
            new Option("Option 2", "btn-success"),
            new Option("Option 3", "btn-primary"),
            new Option("Option 4", "btn-success"),
            new Option("Option 5", "btn-primary"),
            new Option("Option 6", "btn-success"),
            new Option("Option 7", "btn-primary")
        };
        tags = new List<string>() { "Option 2", "Option 5", "Custom Option", "Option 1", "Option 4" };
    }
}

Blazor_TagBox_Template

NOTE

Online Demo: TagBox - Tag Template

Inheritance

Object
TagInfo<T>
See Also