I’m trying to set the active tab programmatically but I cant get it to work, this is the tabs definition
<MudTabs Elevation="1" Rounded="true" @ref="tabs">
and this is the C# code I’m using to set the active tab
public required MudTabs tabs;-- defined at the top of code behind
await InvokeAsync(() => tabs.ActivatePanel(5,true));
await InvokeAsync(StateHasChanged);
the active tab isn’t being set here, If I use a non async version like this
tabs.ActivatePanel(5,true)
await InvokeAsync(StateHasChanged);
I get this error
System.InvalidOperationException HResult=0x80131509 Message=The
current thread is not associated with the Dispatcher. Use
InvokeAsync() to switch execution to the Dispatcher when triggering
rendering or component state. Source=Microsoft.AspNetCore.Components
StackTrace: at
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged() in
/_/src/Components/Components/src/ComponentBase.cs:line 117 at
MudBlazor.MudTabs.d__174.MoveNext() at
System.Threading.Tasks.Task.<>c.b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute() at
System.Threading.ThreadPoolWorkQueue.Dispatch() at
System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
can anyone see what I’m doing wrong here ?