
Display
Displays static text data
Show only
Demo
Two-way binding automatically gets the display labels in the resource file
Demo
When the Dispaly
components turn on bidirectional binding, the Display/DisplayName
label value is automatically obtained based on the Model
property value of the binding and appears as a pre-Label
, with DisplayText
properties you can customize the display of the pre-label, or by turning off the display of the pre-label through the ShowLabel
property
Set the DisplayText
value to custom label
The value of DisplayText
is displayed when ShowLabel
is true
, regardless of whether the value is set
The value of DisplayText
is not displayed when the ShowLabel
is false
The Display
component has built-in processing of enumerated
collections
array
, customize formatting or callback delegate methods if they do not meet the criteria
Demo
The Dispaly
component is used in form components EditorForm
, and is used in detail pages and is not editable
Demo
When you set the FormatString
property value to yyyy-MM-dd
, the component displays a time format of the year and day
Demo
FormatString
Formatter
The Dispaly
component binding byte[]
array, formatted as an example of base64
encoded string
Formatter
Set the Lookup
value to IEnumerable<SelectedItem>
collection, through which the component will perform translations through the Value
display Text
Demo
Value='@IntValue'
set Lookup='@IntValueSource'
component to display the Value
corresponding to the value of the Text
ValueAttributes
@page "/displays"
@inject IStringLocalizer<Displays> Localizer
<h3>Display</h3>
<h4>Displays static text data</h4>
<DemoBlock Title="Basic usage" Introduction="Show only" Name="Normal" Demo="typeof(Demos.Display.DisplayNormal)" />
<DemoBlock Title="Bind data in both directions" Introduction="Two-way binding automatically gets the display labels in the resource file" Name="Labels" Demo="typeof(Demos.Display.DisplayLabels)">
<p>When the <code>Dispaly</code> components turn on bidirectional binding, the <code>Display/DisplayName</code> label value is automatically obtained based on the <code>Model</code> property value of the binding and appears as a <code>pre-Label</code>, with <code>DisplayText</code> properties you can customize the display of the pre-label, or by turning off the display of the pre-label through the <code>ShowLabel</code> property</p>
</DemoBlock>
<DemoBlock Title="Generic binding" Introduction="The <code>Display</code> component has built-in processing of <code>enumerated</code> <code>collections</code> <code>array</code>, customize formatting or callback delegate methods if they do not meet the criteria" Name="DataType" Demo="typeof(Demos.Display.DisplayDataType)" />
<DemoBlock Title="Used within the form" Introduction="The <code>Dispaly</code> component is used in form components <code>EditorForm</code>, and is used in detail pages and is not editable" Name="EditorForm" Demo="typeof(Demos.Display.DisplayEditorForm)" />
<DemoBlock Title="Custom format" Introduction="When you set the <code>FormatString</code> property value to <code>yyyy-MM-dd</code>, the component displays a time format of the year and day" Name="FormatString" Demo="typeof(Demos.Display.DisplayFormatString)" />
<DemoBlock Title="Automatically translated into Text" Introduction="Set the <code>Lookup</code> value to <code>IEnumerable<SelectedItem></code> collection, through which the component will perform translations through the <code>Value</code> display <code>Text</code>" Name="Lookup" Demo="typeof(Demos.Display.DisplayLookup)">
<p>
<div>In this example, the component <code>Value='@IntValue'</code> set <code>Lookup='@IntValueSource'</code> component to display the <code>Value</code> corresponding to the value of the <code>Text</code> Value</div>
<div><b>InitValue</b>: 1,2,3</div>
<div><b>IntValueSource</b>: Text1,Text2,Text3</div>
</p>
</DemoBlock>
<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
/// Display 组件示例
/// </summary>
public partial class Displays
{
private IEnumerable<AttributeItem> GetAttributes() => new[]
{
new AttributeItem() {
Name = "ShowLabel",
Description = Localizer["ShowLabel"],
Type = "bool",
ValueList = "true|false",
DefaultValue = "false"
},
new AttributeItem() {
Name = "DisplayText",
Description = Localizer["DisplayText"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "FormatString",
Description = Localizer["FormatString"],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = "Formatter",
Description = Localizer["Formatter"],
Type = "RenderFragment<TItem>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = nameof(Display<string>.TypeResolver),
Description = Localizer["TypeResolver"],
Type = "Func<Assembly?, string, bool, Type?>",
ValueList = " — ",
DefaultValue = " — "
}
};
}