'Create blazor component based on InputBase with interface
I need to create a Blazor component inherited from the Microsoft.AspNetCore.Components.Forms.InputBase class that implements an interface.
My interface is realised with this code :
public interface Person
{
public Guid Id { get; set; }
public string Name { get; set; }
public string FirstName { get; set; }
}
And my class who inherit of interface is
public class Child : Person
{
private Guid id;
private string name;
private string firstName;
public Guid Id { get => id; set => id = value; }
public string Name { get => name ; set => name = value; }
public string FirstName { get => firstName; set => firstName = value; }
public Child(string name, string firstname)
{
this.name = name;
this.firstName = firstname;
}
}
For my component this inherit of InputBase is declared with :
@inherits Microsoft.AspNetCore.Components.Forms.InputBase<Person?>
For use my component in blazor page, I have used the code below :
<MyTest @bind-Value="@child" />
When I generate my solution, I have an error :
Error CS1503 Argument 2: cannot convert from 'Microsoft.AspNetCore.Components.EventCallback<Test.Children>' to 'Microsoft.AspNetCore.Components.EventCallback'
Can you help me understand this mistake? Do I need to create a specific getter/setter to transform the Child into a Person or is there another solution?
Thanks for your help ! Vincent
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
