How to fix ‘The current thread is not associated with the renderer’s synchronization context’?

I have just implemented a State Container like this and ran into the same error – but my service needs to be a singleton. So I found an example on the aspnetcore git that does exactly what the error message says to do. Call InvokeAsync — not from your state container but when you try … Read more

How to animate state transitions in Blazor?

Blazor doesn’t cover this scenario, for this, you would need to use CSS. It’s hard to give you a specific example as it depends on exactly how you want your animations to work and with what kind of style but I would suggest checking out CSS transitions and keyframes. Here are some good resources https://www.w3schools.com/css/css3_transitions.asp … Read more

Is there a way to globally catch all unhandled errors in a Blazor single page application?

In .NET 6 there is component called ErrorBoundary. Simple example: <ErrorBoundary> @Body </ErrorBoundary> Advanced Example: <ErrorBoundary> <ChildContent> @Body </ChildContent> <ErrorContent Context=”ex”> @{ OnError(@ex); } @*calls custom handler*@ <p>@ex.Message</p> @*prints exeption on page*@ </ErrorContent> </ErrorBoundary> For the global exception handling I see this as an option: Create CustomErrorBoundary (inherit the ErrorBoundary) and override the OnErrorAsync(Exception exception). … Read more

how to call child component method from parent component in blazor?

First you need to capture a reference of your child component: <ChildComponent @ref=”child” /> Then you can use this reference to call the child’s component methods as you do in your code. <button onClick=”@ShowModal”>show modal</button> @code{ ChildComponent child; void ShowModal(){ child.Show(); } } The namespace of your component need to be added by a using … Read more

Blazor – cannot convert from ‘method group’ to ‘EventCallback’

You were close: <ChildComponent Item=”someModel” T=”SomeModel” DeleteCallback=”OnDeleteSomeModel” /> @code { SomeModel someModel = new SomeModel(); void OnDeleteSomeModel(SomeModel someModel) { … } } The EventCallback uses a generic type and blazor cannot infer it if you don’t pass the type to the component. This means that if you have a EventCallback<T> you need to pass the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)