我使用的是electron.Net,但当我启动主窗口时,它总是打开与中心对齐的小尺寸窗口。
这是我的代码:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Task.Run(async () => await Electron.WindowManager.CreateWindowAsync());
Electron.Menu.SetApplicationMenu(new MenuItem[] {});
}发布于 2020-07-04 17:51:33
基于BrowserWindow source和Electron.NET Demo,下面的命令在最大化窗口中打开电子窗口。
这只是在显示窗口之后,当一切准备就绪时,手动调用BrowserWindow的Maximize()事件。
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
if (HybridSupport.IsElectronActive)
{
ElectronBootstrap();
}
}
public async void ElectronBootstrap()
{
var browserWindow = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
{
Width = 1152,
Height = 940,
Show = false
});
await browserWindow.WebContents.Session.ClearCacheAsync();
// For the gracefull showing of the Electron Window when ready
browserWindow.OnReadyToShow += () =>
{
browserWindow.Show();
browserWindow.Maximize();
}
Electron.Menu.SetApplicationMenu(new MenuItem[] {});
} 希望这能有所帮助。
https://stackoverflow.com/questions/62726612
复制相似问题