question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Transparent window has white background

See original GitHub issue
  • Electron.NET Version 23.6.1
  • .NET Core Version 7.0
  • Node.js Version 18.12
  • Target: Windows

I have created a window like so:

var window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions()
{
   Resizable = false,
   Fullscreen = true,
   Minimizable = false,
   Movable = false,
   Frame = false,
   Transparent = true,
   BackgroundColor = "#00000000",
});
window.SetAlwaysOnTop(true, OnTopLevel.screenSaver);

Expecting the background the be transparent, but instead it is white. (The page itself only contains one <p> element, nothing more) I tried adding some delay before calling CreateWindowAsync, as I saw it solved the issue for some people using normal Electron, but that did not help either.

Any idea how can I fix this?

Issue Analytics

  • State:closed
  • Created 6 months ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Yuvix25commented, Mar 29, 2023

@GregorBiswanger Yes! That’s it. Your solution works perfectly 👌🏻

1reaction
GregorBiswangercommented, Mar 29, 2023

image

I built a Blazor server app and it works without any problems. See the screenshot.

For this I changed the site.css in the wwwroot/css directory:

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: transparent;
}

This is my Electron.NET startup code:

using ElectronNET.API;
using ElectronNET.API.Entities;
using ElectronNetTransparentWindow.Data;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseElectron(args);

builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<WeatherForecastService>();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");

await app.StartAsync();


await Task.Run(async () =>
{
    Electron.App.CommandLine.AppendSwitch("enable-transparent-visuals");
    Electron.App.CommandLine.AppendSwitch("disable-gpu-compositing");

    var browserWindowOptions = new BrowserWindowOptions
    {
        Frame = false,
        Transparent = true
    };

    await Electron.WindowManager.CreateWindowAsync(browserWindowOptions);
});

await app.WaitForShutdownAsync();

did you make it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transparent window has white background window #2170
Hi, I've some issue with the transparent window, my code is: win = new BrowserWindow({ width: 100, height: 50, transparent: true, ...
Read more >
Transparent image showing up with white background on ...
jpg just gives a white background, but it shows in Files as a Black ... Clicking on the top bar of the window...
Read more >
Media videos have a white transparent background
Media videos have a white transparent background. Hey, so I have an error. It started with just the films and movie app and...
Read more >
Make a non-frameless Electron window have a transparent ...
The window still have the default white background. Is it possible to have a transparent window in Electron without it being frameless?
Read more >
Windows 10 transparent Icons on a white background
I've noticed that icons that are supposed to have a transparent background have a white background instead. enter image description here. I've ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found