Вход на сайт
Подарки от программис'тов
6208 просмотров
Перейти к просмотру всей ветки
alex445 коренной житель
в ответ alex445 22.08.22 17:51, Последний раз изменено 22.08.22 18:17 (alex445)
Вобщем, как выглядит моя обёртка (часть кода) над кастомным базовым типом строки StringDataItem Data
public enum VisibilityEnum { Enabled, Disabled, Hidden, Collapsed, } public class InputTextComponent : ComponentBase { [Parameter] public StringDataItem Data { get; set; } // custom string data type string Value { get => Data.Value; // I can read the value only through this property... set => Data.SetValue(value); // and set it only through this methode. } bool Disabled => Data.VisibleStyle == VisibilityEnum.Disabled; // used with "disabled" HTML attribute string Visibility => Data.VisibleStyle switch { VisibilityEnum.Collapsed => "collapse", // Bootstrap style class VisibilityEnum.Hidden => "invisible", // Bootstrap style class _ => string.Empty, }; }
И как я использую это в разметке для своего строкового компонента для ввода (часть кода)
<input type="text" @bind="Value" disabled="@Disabled" class="@Visibility" />