Created
June 3, 2021 07:40
-
-
Save vnbaaij/4b85d0076b20f1e0cb369b424d9ae07b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/choiceGroupPage" | |
@using System.Collections.Generic | |
<header class="root"> | |
<h1 class="title">ChoiceGroup</h1> | |
</header> | |
<div class="section" style="transition-delay: 0s;"> | |
<div id="overview" tabindex="-1"> | |
<h2 class="subHeading">Usage</h2> | |
</div> | |
<div> | |
<div class="subSection"> | |
<Demo Header="ChoiceGroup with ItemSource as List<IChoiceGroupOption>" MetadataPath="ChoiceGroupPage" Key="1"> | |
<Stack> | |
<ChoiceGroup ItemsSource="this._choiceGroupOptions!" TItem="ChoiceGroupOption" Value="this._selectedChoiceGroupOption" ValueChanged="OnValueChanged"> | |
</ChoiceGroup> | |
<br /> | |
<div> | |
Selected option: @(_selectedChoiceGroupOption?.Label ?? "none") | |
</div> | |
</Stack> | |
</Demo> | |
</div> | |
<div style="height:150px"></div> | |
</div> | |
</div> | |
@code { | |
private ChoiceGroupOption? _selectedChoiceGroupOption; | |
private List<ChoiceGroupOption> _choiceGroupOptions = new List<ChoiceGroupOption> | |
{ | |
new ChoiceGroupOption{ Label = "Option A" }, | |
new ChoiceGroupOption{ Label = "Option B" }, | |
new ChoiceGroupOption{ Label = "Option C", IsDisabled = true }, | |
new ChoiceGroupOption{ Label = "Option D" }, | |
}; | |
private class ChoiceGroupOption : IChoiceGroupOption | |
{ | |
public string? Label { get; set; } | |
public bool IsDisabled { get; set; } = false; | |
public bool IsVisible { get; set; } = true; | |
} | |
protected override void OnParametersSet() | |
{ | |
_selectedChoiceGroupOption = _choiceGroupOptions[2]; | |
base.OnParametersSet(); | |
} | |
private void OnValueChanged(ChoiceGroupOption item) | |
{ | |
item.ToString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment