コード例 #1
0
    /// <inheritdoc />
    protected override void OnParametersSet()
    {
        var groupName           = !string.IsNullOrEmpty(Name) ? Name : _defaultGroupName;
        var fieldClass          = EditContext?.FieldCssClass(FieldIdentifier) ?? string.Empty;
        var changeEventCallback = EventCallback.Factory.CreateBinder <string?>(this, __value => CurrentValueAsString = __value, CurrentValueAsString);

        _context = new InputRadioContext(CascadedContext, groupName, CurrentValue, fieldClass, changeEventCallback);
    }
コード例 #2
0
        /// <summary>
        /// Adds the specified field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="context">The context.</param>
        /// <returns>ClassList.</returns>
        public ClassList Add(FieldIdentifier field, EditContext context)
        {
            if (field.FieldName != null && context != null)
            {
                return(Add(context.FieldCssClass(field)));
            }

            return(this);
        }
コード例 #3
0
    /// <inheritdoc />
    protected override void OnParametersSet()
    {
        // On the first render, we can instantiate the InputRadioContext
        if (_context is null)
        {
            var changeEventCallback = EventCallback.Factory.CreateBinder <string?>(this, __value => CurrentValueAsString = __value, CurrentValueAsString);
            _context = new InputRadioContext(CascadedContext, changeEventCallback);
        }
        else if (_context.ParentContext != CascadedContext)
        {
            // This should never be possible in any known usage pattern, but if it happens, we want to know
            throw new InvalidOperationException("An InputRadioGroup cannot change context after creation");
        }

        // Mutate the InputRadioContext instance in place. Since this is a non-fixed cascading parameter, the descendant
        // InputRadio/InputRadioGroup components will get notified to re-render and will see the new values.
        _context.GroupName    = !string.IsNullOrEmpty(Name) ? Name : _defaultGroupName;
        _context.CurrentValue = CurrentValue;
        _context.FieldClass   = EditContext?.FieldCssClass(FieldIdentifier);
    }