Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Creating a Tri-State checkbox component for blazor

$
0
0

<input @bind="Checked" type="checkbox" @onclick="eventArgs => { onclick(); }" indeterminate="@indeterminate" class="checkbox-input">@code {    [Parameter]    public bool? selected { get; set; } = null;    public bool indeterminate { get; set; }    public bool Checked { get; set; }    public void onclick()    {        selected = selected == null ? true : selected == true ? new bool?() : false;        Checked = selected == null || selected == false;        indeterminate = selected == null;    }}

This doesn't produce the desired result

The checkbox is always either checked or unchecked, never indeterminate.

Any ideas?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>