Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement the use of CenterScreen #55

Open
1 task done
PabloKench opened this issue Nov 24, 2024 · 2 comments
Open
1 task done

implement the use of CenterScreen #55

PabloKench opened this issue Nov 24, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@PabloKench
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I started using blazor desktop, I noticed that it uses wpf, but I can't find a way to use WindowStartupLocation as CenterScreen

Describe the solution you'd like

Implementing this would be good, since most apps today are opened as centralized

Additional context

No response

@PabloKench PabloKench added the enhancement New feature or request label Nov 24, 2024
@AndrewBabbitt97
Copy link
Collaborator

Most apps should actually remember the last location an app was used / opened at which is the bigger problem as I don't believe that works currently. The current settings should be the windows default behavior, where Windows will open multiple windows from the top left corner, you can see this behavior in File Explorer.

As a workaround you should be able to get access to the BlazorDesktopWindow in Program.cs and set the property yourself:

using BlazorDesktop.Hosting;
using HelloWorld.Components;
using Microsoft.AspNetCore.Components.Web;

var builder = BlazorDesktopHostBuilder.CreateDefault(args);

builder.RootComponents.Add<Routes>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

if (builder.HostEnvironment.IsDevelopment())
{
    builder.UseDeveloperTools();
}

var app = builder.Build();

var window = app.Services.GetRequiredService<BlazorDesktopWindow>();

window.WindowStartupLocation = WindowStartupLocation.CenterScreen;

await app.RunAsync();

@AndrewBabbitt97
Copy link
Collaborator

Realistically we need to evaluate better window options, this ties into #42

It would probably be better if we also exposed the main window as a property under the BlazorDesktopHostBuilder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants