Can't change the bounds on a BrowserView before calling browserWindow.SetBrowserView #539

Closed
opened 2026-01-29 16:42:23 +00:00 by claunia · 1 comment
Owner

Originally created by @MopsieX on GitHub (Jul 25, 2020).

Originally assigned to: @GregorBiswanger on GitHub.

  • Version: 9.31.2

Steps to Reproduce:

  1. Create a BrowserWindow
BrowserWindow browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
            {
                Width = 500,
                Height = 500,
                Frame = false,
                Transparent = true
            });
  1. Create a BrowserView(BrowserView bv = await Electron.WindowManager.CreateBrowserViewAsync();)
  2. Set the Bounds of the BrowserView
var bounds = await browserWindow.GetBoundsAsync(); 
bv.Bounds = new Rectangle() { Height = bounds.Height, Width = bounds.Width, X = 0, Y = 0};
  1. Set the BrowserView(browserWindow.SetBrowserView(bv))

If you set the bounds of the BrowserView before you call SetBrowserView the BrowserView's bounds will be {0,0,0,0}. Once you call SetBrowserView you can then set its bounds.

Originally created by @MopsieX on GitHub (Jul 25, 2020). Originally assigned to: @GregorBiswanger on GitHub. <!-- Please search existing issues to avoid creating duplicates. --> <!-- Which version of Electron.NET CLI and API are you using? --> <!-- Please always try to use latest version before report. --> * **Version**: 9.31.2 Steps to Reproduce: 1. Create a BrowserWindow ``` BrowserWindow browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Width = 500, Height = 500, Frame = false, Transparent = true }); ``` 2. Create a BrowserView(`BrowserView bv = await Electron.WindowManager.CreateBrowserViewAsync();`) 3. Set the Bounds of the BrowserView ``` var bounds = await browserWindow.GetBoundsAsync(); bv.Bounds = new Rectangle() { Height = bounds.Height, Width = bounds.Width, X = 0, Y = 0}; ``` 4. Set the BrowserView(`browserWindow.SetBrowserView(bv)`) If you set the bounds of the BrowserView before you call SetBrowserView the BrowserView's bounds will be {0,0,0,0}. Once you call SetBrowserView you can then set its bounds.
claunia added the bug label 2026-01-29 16:42:23 +00:00
Author
Owner

@GregorBiswanger commented on GitHub (Mar 28, 2023):

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

@GregorBiswanger commented on GitHub (Mar 28, 2023): 🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉 With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/Electron.NET#539