I have a Blazor component with a parameter Position. This parameter should only accept Top or Bottom for values.
Is it possible set up "intellisense" for this, so when value for Position should be entered a pop-up with only these to settings goes out?
Position.cs
public enum Position
{
Top,
Bottom
}
MyComponent.razor
@inherits MyComponentBase
<div class="@PositionClass"></div>
MyComponent.razor.cs
public class MyComponentBase : ComponentBase
{
[Parameter] public Position Position { get; set; } = ToastPosition.TopRight;
protected string PositionClass { get; set; } = string.Empty;
]
Index.razor
<MyComponent Position="Position.Bottom" />
Your problem is here
// here \/
Position="Position.Bottom"
For the intellisense, you are passing a string because you haven't used the @ symbol.
When typing, you should do Position="(CURSOR IS HERE)" and then type @ so it will get the correct intellisense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With