ant-design-blazor/site/AntDesign.Docs/Demos/Components/Tabs/demo/CustomAddTrigger.razor
James Yeung 3a295f5c54 feat(module: tabs): add OnClose event and TabTemplate (#1698)
* feat(module: tab): add onclose event and tabtemplate

* add tests
2021-07-02 01:16:53 +08:00

32 lines
888 B
C#

<div>
<div style="margin-bottom: 16px;">
<Button @onclick="(e)=>Add()">ADD</Button>
</div>
<Tabs Type="@TabType.EditableCard" HideAdd @bind-ActiveKey="activeKey">
@foreach (var pane in panes)
{
<TabPane Key="@pane.Key" Tab="@pane.Title">
@pane.Content
</TabPane>
}
</Tabs>
</div>
@code{
private string activeKey;
private int newTabIndex;
public record Pane(string Title, string Content, string Key, bool Closable = true);
List<Pane> panes = new List<Pane>() {
new("Tab 1", "Content of Tab Pane 1","1"),
new("Tab 2", "Content of Tab Pane 2","2"),
new("Tab 3", "Content of Tab Pane 3","3",false),
};
private void Add()
{
activeKey = $"newTab{newTabIndex++}";
panes.Add(new Pane($"New Tab", $"New Tab Pane", activeKey));
}
}