반응형
div로 묶어서 RadioButton 설정
<div class="radio_btn">
<SfRadioButton Label="레디오1" Value="r1" @bind-Checked="rChecked"></SfRadioButton>
<SfRadioButton Label="레디오2" Value="r2" @bind-Checked="rChecked"></SfRadioButton>
<SfRadioButton Label="레디오3" Value="r3" @bind-Checked="rChecked"></SfRadioButton>
</div>
blazor @code{}안에 선언
@code{
private string rChecked = "r1";
private string getCssVisibility(string checkedValue, string targetValue)
{
return checkedValue == targetValue ? "" : "d-none";
}
}
//d-done은 css을 담을 이름
//"r1"은 Chcked된 옵션
blazor <style></style> 안에 선언
<style>
.d-none {
display:none;
}
</style>
각 RadioButton에 사용 할 div들 선언
<div class="@getCssVisibility(rChecked,"r1")">
//해당 RadioButton의 보여 줄 컴포넌트나 소스 작성
</div>
전체 소스
<div>
<div class="radio_btn">
<SfRadioButton Label="레디오1" Value="r1" @bind-Checked="rChecked"></SfRadioButton>
<SfRadioButton Label="레디오2" Value="r2" @bind-Checked="rChecked"></SfRadioButton>
<SfRadioButton Label="레디오3" Value="r3" @bind-Checked="rChecked"></SfRadioButton>
</div>
<div class="@getCssVisibility(rChecked,"r1")">
//해당 RadioButton의 보여 줄 컴포넌트나 소스 작성
</div>
<div class="@getCssVisibility(rChecked,"r2")">
//해당 RadioButton의 보여 줄 컴포넌트나 소스 작성
</div>
<div class="@getCssVisibility(rChecked,"r3")">
//해당 RadioButton의 보여 줄 컴포넌트나 소스 작성
</div>
</div>
@code{
private string rChecked = "r1";
private string getCssVisibility(string checkedValue, string targetValue)
{
return checkedValue == targetValue ? "" : "d-none";
}
}
<style>
.d-none {
display:none;
}
</style>
반응형
'C#' 카테고리의 다른 글
[Blazor] 자식 Components data변경 부모 Components로 전달하기! (0) | 2024.08.23 |
---|---|
[Blazor] Css에 조건 걸어서 사용하기 (0) | 2024.06.28 |
[Blazor] 컴포넌트 간 데이터 받는 방법 (0) | 2024.06.27 |
자식 폼에서 부모 폼의 메소드(함수) 사용하기 (0) | 2023.11.03 |