Esempio n. 1
0
        /// <inheritdoc/>
        public override async Task SetParametersAsync(ParameterView parameters)
        {
            await base.SetParametersAsync(parameters);

            // For modals we need to make sure that autofocus is applied every time the modal is opened.
            if (parameters.TryGetValue <bool>(nameof(Autofocus), out var autofocus) && this.autofocus != autofocus)
            {
                this.autofocus = autofocus;

                if (autofocus)
                {
                    if (ParentFocusableContainer != null)
                    {
                        ParentFocusableContainer.NotifyFocusableComponentInitialized(this);
                    }
                    else
                    {
                        ExecuteAfterRender(() => Focus());
                    }
                }
                else
                {
                    ParentFocusableContainer?.NotifyFocusableComponentRemoved(this);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Shared code to dispose of any internal resources.
        /// </summary>
        protected virtual void ReleaseResources()
        {
            if (ParentValidation != null)
            {
                // To avoid leaking memory, it's important to detach any event handlers in Dispose()
                ParentValidation.ValidationStatusChanged -= OnValidationStatusChanged;
            }

            ParentFocusableContainer?.NotifyFocusableComponentRemoved(this);

            if (Theme != null)
            {
                Theme.Changed -= OnThemeChanged;
            }
        }