| | | 1 | | <RadzenStack Orientation="Orientation.Horizontal" Gap="0.5rem" AlignItems="AlignItems.Center" Style="@Style" class="chec |
| | | 2 | | <RadzenCheckBox Value="@Value" |
| | | 3 | | TValue="bool" |
| | | 4 | | Change="@OnInternalValueChanged" |
| | | 5 | | Name="@ComponentId" |
| | | 6 | | Disabled="@Disabled" |
| | | 7 | | @attributes="AdditionalAttributes" /> |
| | | 8 | | <RadzenLabel Text="@Text" Component="@ComponentId" Style="flex: 1; cursor: pointer;" /> |
| | | 9 | | </RadzenStack> |
| | | 10 | | |
| | | 11 | | @code { |
| | 5 | 12 | | [Parameter] public string Text { get; set; } = string.Empty; |
| | 3 | 13 | | [Parameter] public bool Value { get; set; } |
| | 0 | 14 | | [Parameter] public EventCallback<bool> ValueChanged { get; set; } |
| | 3 | 15 | | [Parameter] public bool Disabled { get; set; } |
| | 2 | 16 | | [Parameter] public string? Style { get; set; } |
| | | 17 | | |
| | | 18 | | // Позволяет передавать любые другие атрибуты RadzenSwitch (напр. Title, TabIndex) |
| | | 19 | | [Parameter(CaptureUnmatchedValues = true)] |
| | 2 | 20 | | public Dictionary<string, object>? AdditionalAttributes { get; set; } |
| | | 21 | | |
| | 2 | 22 | | private string ComponentId = $"switch_{Guid.NewGuid()}"; |
| | | 23 | | |
| | | 24 | | private async Task OnInternalValueChanged(bool newValue) |
| | | 25 | | { |
| | | 26 | | // Уведомляем родителя об изменении |
| | 0 | 27 | | await ValueChanged.InvokeAsync(newValue); |
| | 0 | 28 | | } |
| | | 29 | | } |