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

Which approach is best to create radio type input dialog page in Blazor?

$
0
0

Here is a portion of code. Before I did radio type input I had been using the range type input where Pizza.Size property had had data via @bind="Pizza.Size". But as you see @bind="Pizza.Size" is not working anymore.

<form class="dialog-body"><div><label>            Rozmiar: </label><InputRadioGroup @bind-Value="Pizza.Size">        @foreach (var size in Pizza.AllowedValues)        {<InputRadio Value="size"/><span class="size-label">@size cm</span>        }</InputRadioGroup></div></form><div class="dialog-buttons"><button class="btn btn-secondary mr-auto" @onclick="OnCancel">Anuluj</button><span class="mr-center">         Cena: <span class="price">@(Pizza.GetFormattedTotalPrice())</span></span><button class="btn btn-success ml-auto" @onclick="OnConfirm">Zamów</button></div>
@code {    [Parameter] public Pizza Pizza { get; set; }    [Parameter] public EventCallback OnCancel { get; set; }    [Parameter] public EventCallback OnConfirm { get; set; }}

Pizza model:

public class Pizza{    public const int DefaultSize = 32;    public const int MinimumSize = 28;    public const int MaximumSize = 50;    public static int[] AllowedValues { get; set; } = { 28, 32, 42, 50 };   ...    public int Size { get; set; }    public decimal GetBasePrice()    {        return ((decimal)Size / (decimal)DefaultSize) * Special.BasePrice;    }    public decimal GetTotalPrice()    {        return GetBasePrice();    }    public string GetFormattedTotalPrice()    {        return GetTotalPrice().ToString("0.00");    }}

Viewing all articles
Browse latest Browse all 4839

Trending Articles



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