jspuij/TwokaB

Hiding until render?

garrynewman opened this issue · 2 comments

Is there a simple way to hide the view until it's fully rendered?

My window is dark so it's a bit jarring to have a white screen show up just before loading in. I see some messaging functions but I'm not really sure how to use them. I could have a guess timer but I'd like to do it properly if possible.

(I'm using it in WPF)

I did not expose the document ready events from all the views because the browser thinks it's ready when the initial HTML is loaded (although probably the white screen can be avoided with just css), then blazor still needs to initialize, so it's a bit early.

What you can do is hide or collapse the BlazorWebView inside the WPF window. Then override the OnAfterRenderAsync in the App.Razor root component (check for firstRender!).

When firstRender is true here, call a method on the Wpf Window to unhide / expand the BlazorWebView. (Make sure you invoke it through the Wpf Window dispatcher, not through the Blazor Component dispatcher, because the main blazor thread != main wpf thread).

Let me know if this makes sense to you, otherwise I'll see if I can cook up a quick example.

That worked great - thanks!