using the following interface:
public interface INameable
{
/// <summary>
/// The customer provided name of the object
/// </summary>
public string Name { get; set; }
/// <summary>
/// combination of the ObjectName and the customer provided name used to quickly display items in lists to prevent the need for reflexction
/// </summary>
public string ObjectAndName => $"({ObjectName}) {Name}";
/// <summary>
/// The coloquial name of the object
/// </summary>
public string ObjectName { get; }
}
and this class
public class Ink : Changeable, INameable
{
[Key]
public Guid InkId { get; init; } = Guid.NewGuid();
public string Color { get; set; }
public string Name { get => Color; set => Color = value; }
public string ObjectName => "Ink";
}
when i use it in a datalist like so:
<RadzenListBox
TValue="INameable"
Data="Data"
@bind-Value=newModifier.Nameable
Multiple="false"
AllowFiltering="true"
FilterAsYouType="true"
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
FilterOperator="StringFilterOperator.Contains"
TextProperty="ObjectAndName"
Style="width:100%; height:477px"
/>
I get the following displayed:
if i use the name property as the textProperty
i get this display result:
if i use the objectName
property as the text property, i get this display:
I know it is the ToString
method being called as I have other classes in this filtered list which display the return of their ToString overriden method.
both the properties ObjectName
and Name
are defined per class. Why is the default interface implementation returning the class's ToString
method?