Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor - Component "intellisense" for parameter value

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" />
like image 493
imb13 Avatar asked Jul 04 '26 01:07

imb13


1 Answers

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.

like image 156
Vencovsky Avatar answered Jul 05 '26 15:07

Vencovsky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!