mirror of
https://github.com/PacktPublishing/Web-Development-with-Blazor-Second-Edition.git
synced 2026-04-08 15:54:02 +00:00
Initial commit
This commit is contained in:
parent
2190113c56
commit
3088165398
1765 changed files with 192085 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
namespace Components;
|
||||
|
||||
public class CustomCssClassProvider<ProviderType> : ComponentBase where ProviderType : FieldCssClassProvider, new()
|
||||
{
|
||||
[CascadingParameter]
|
||||
EditContext? CurrentEditContext { get; set; }
|
||||
public ProviderType Provider { get; set; } = new ProviderType();
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (CurrentEditContext == null)
|
||||
{
|
||||
throw new InvalidOperationException($"{nameof(CustomCssClassProvider<ProviderType>)} requires a cascading parameter of type {nameof(EditContext)}. For example, you can use {nameof(CustomCssClassProvider<ProviderType>)} inside an EditForm.");
|
||||
}
|
||||
CurrentEditContext.SetFieldCssClassProvider
|
||||
(Provider);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue