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

Alternative to IWpfShell #32

Open
mgnslndh opened this issue Dec 17, 2020 · 2 comments
Open

Alternative to IWpfShell #32

mgnslndh opened this issue Dec 17, 2020 · 2 comments

Comments

@mgnslndh
Copy link
Contributor

Hi Robin!

I've been playing around some more with the library and I wonder if it would be possible to find an alternative solution to the IWpfShell marker interface. Let's say that the shell is located in separate assembly from the host. It would be nice to avoid the dependency on the marker interface in that case.

Perhaps the API could have a method UsingWpfShell<TShell>() instead and use the provided type for lookup.

Or would you say this is out of scope and rather recommend using a custom implementation of ConfigureWpf alltogether?

@mgnslndh
Copy link
Contributor Author

I worked around this by not using the IWpfShell interface at all and instead used the following startup code:

public partial class MyApplication : Application
{
    protected override void OnStartup(StartupEventArgs e)
    {
        MainWindow = new ShellView();
        MainWindow.Show();
        MainWindow.Activate();
        base.OnStartup(e);
    }
}

@Lakritzator
Copy link
Member

Hi Magnus,

sorry for the delay, so much to do...

I agree that if you want to provide your shell in a separate assembly, it's unfortunate to add a dependency to my library.
My assumption was that in most cases you'd use a plugin (IPlugin), so it can configure the dependencies, which needs dependencies anyway. But as you already saw, there is no direct NEED to use IWpfShell, this is only a convenience to make automatically open a window.

FYI: The logic for the IWpfShel can be found here: https://github.com/dapplo/Dapplo.Microsoft.Extensions.Hosting/blob/master/src/Dapplo.Microsoft.Extensions.Hosting.Wpf/Internals/WpfThread.cs#L69

You also don't NEED an application, but it's possible to override it's behavior to do exactly that what you did.

I'm sure I can extend the configuration to add something that will add a similar behavior, without the need for you to add dependencies, but I prefer to keep the configuration small & simple as it will get way to many border-cases.
But I'm always happy to discuss this!

If you are happy with your current solution, let me know and we can close this issue.

P.S.
I'm slightly confused with your question, as the whole idea of this project is using the hosting feature to make UI's work with dependency injection right out of the box. Maybe you have a service which also needs an already written UI and you more or less don't need the added service "ballast" to your UI? So I love to hear more about your use-case, like what you are doing with this project. This helps me to predict if future enhancement / fixes are in line with what you are doing.

Best wishes,
Robin

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

No branches or pull requests

2 participants