DialogService problem

Hello. I try to add DialogService to my razor page. It should open when I click on dataColumn in my DataGrid. I looked at the examples, but when I use the example code, I get syntax error :

|CS0120|An object reference is required for the non-static field, method, or property 'DialogService.OpenAsync(string, RenderFragment, DialogOptions)'|SFADataTools.BlazorServerApp|C:\Development\SFA 365\DataTools\SFADataTools.BlazorServerApp\Pages\DataLoader.razor|91||

Here is the code I use:

async Task ShowInlineDialog()
{
    var result = await DialogService.OpenAsync("Simple Dialog", ds =>
@<RadzenStack Gap="1.5rem">
    <p>Test</p>
    <RadzenStack Orientation="Orientation.Horizontal" Gap="0.5rem" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.SpaceBetween">
        <RadzenStack Orientation="Orientation.Horizontal">
            <RadzenButton Text="Ok" Click="() => ds.Close(true)" Style="width: 80px;" />
            <RadzenButton Text="Cancel" Click="() => ds.Close(false)" ButtonStyle="ButtonStyle.Light" />
        </RadzenStack>
        <RadzenButton Text="Refresh" ButtonStyle="ButtonStyle.Light" />
    </RadzenStack>
</RadzenStack>);
}

And where is the service injected?

1 Like

Thank you. I really forgot to inject the class.