TagInfo<T>.IsCustom Property
Gets a value that specifies whether the processed tag is custom.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v22.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public bool IsCustom { get; }
Property Value
Type | Description |
---|---|
Boolean | true, if the processed tag is custom; otherwise, false. |
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="@nameof(City.CityName)"
TData="City"
TValue="City"
AllowCustomTags ="true"
@bind-Tags="@Tags">
<TagTemplate Context="tagInfo">
@{
var styleMode = tagInfo.IsCustom ? ButtonRenderStyleMode.Contained: GetModeByID(tagInfo.DataItem.CountryId);
var style = tagInfo.IsCustom ? ButtonRenderStyle.Dark : ButtonRenderStyle.Primary;
<DxButton RenderStyle="@style"
RenderStyleMode="@styleMode"
Text="@tagInfo.Text"
style="display:inline-block">
@context
<span @onclick="@tagInfo.RemoveTagAction">×</span>
</DxButton>
}
</TagTemplate>
</DxTagBox>
@code {
List<City> DataSource { get; set; }
IEnumerable<string> Tags { get; set; }
ButtonRenderStyleMode GetModeByID(int countryId) {
switch (countryId) {
case 0: return ButtonRenderStyleMode.Contained;
case 1: return ButtonRenderStyleMode.Outline;
default: return ButtonRenderStyleMode.Text;
}
}
protected override void OnInitialized() {
base.OnInitialized();
DataSource = CityData.Cities;
Tags = new List<string>() { "Los Angeles", "Tokyo", "Moscow" };
}
}
See Also