본문 바로가기

워크

blazor MatTab

@page "/Events"
@inject NavigationManager NavigationManager

<MatButton OnClick="@ChangeTab">Change Tab</MatButton>
<div>
    Active tab index: @tabIndex
</div>
<div>
    Onclick index: @tabClickIndex
</div>
<MatTabGroup @bind-ActiveIndex="@tabIndex" @onclick="ClickHandler">

    <MatTab Label="First">
        First Content
    </MatTab>
    <MatTab Label="Second">
        Second Content
    </MatTab>
    <MatTab Label="Third">
        Third Content
    </MatTab>
    <MatTab Label="Fourth">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth1">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth2">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth3">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth4">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth5">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth6">
        Fourth Content
    </MatTab>
    <MatTab Label="Fourth7">
        Fourth Content
    </MatTab>

</MatTabGroup>

@code {
    public int tabIndex = 0;
    public int tabClickIndex = 0;
    // to redirect the user, do something like this:
    //uriHelper.NavigateTo("/yourPage"); // to do a dynamic refresh with injected UriHelper
 
    //navMan.NavigateTo("/yourPage", true); // to also force page refresh instead of a dynamic load with injected NavigationManager
    void ClickHandler()
    {
        if (!tabIndex.Equals(2))
        {
            NavigationManager.NavigateTo("/Counter");
        }

        tabClickIndex = tabIndex;
    }

    void ChangeTab(MouseEventArgs e)
    {
        tabIndex = tabIndex < 3 ? tabIndex + 1 : 0;
    }
}

'워크' 카테고리의 다른 글

blazor Cookie  (0) 2020.07.15
sessionStorage localStorage  (0) 2020.07.15
NavigationManager 시트  (0) 2020.07.12
BlazorInputFile FileUpload  (0) 2020.07.11
특정 폴더의 특정 확장자들 지정해서 파일 가져오기  (0) 2020.07.11