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

Add MsExtensionsHostingSample sample project #64

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

maxkatz6
Copy link
Member

@maxkatz6 maxkatz6 commented Nov 3, 2023

What does the pull request do?

Adds a sample project on how to use .NET Generic Host in a typical Avalonia app.

Scope of this PR:

  • fix or update to an existing sample
  • add a new sample

Checklist

If this is a new Sample

In any case

  • Spell-checking done
  • Checked if all hyperlinks work
  • Checked if all images are visible

Fixed issues

Fixes #35

@maxkatz6 maxkatz6 marked this pull request as draft November 4, 2023 07:11
@pjmagee
Copy link

pjmagee commented Dec 18, 2023

I have been using this branch as a basis for my IHost usage but struggled when it came to multi views using the MainWindowViewModel which needs to change the Views its currently presenting on the main window, since its 1 window, multi pages (buttons go to different views - I have one main view, but a settings view) - I only want the 1 window.

I came across some issues understanding how that works with the ViewLocator and the DI registration of MainWindowViewModel only being bound to one View.

Not sure if something would need to change a bit with the DI to make a foundation for Windows extensions generic host with a "starting example" for navigation.

@timunie
Copy link
Collaborator

timunie commented Dec 19, 2023

@pjmagee typically you would have two ViewModels for two views where each VM is represented by a DataTemplate. Then if you swap DataContext of your Window, you should be navigated automatically. Check also the NavigationSample (okay it's without DI but concept should be similar)

@pjmagee
Copy link

pjmagee commented Dec 19, 2023

ahh, thank you. Checking out now

@jedidja
Copy link

jedidja commented Jan 2, 2024

Wow what awesome timing for this PR! I just started looking into Avalonia and this was my first question :) Thanks for working on this. @maxkatz6 apart from the "in any case" items, is there anything you consider missing from the sample?

@mrmorrandir
Copy link

Why is the GlobalHost a public property here? I always keep the host private, in order to guard it from outside access.
You should not need it anywhere else in your code, because you use DI anyway, or am I missing details?

@pjmagee
Copy link

pjmagee commented Sep 29, 2024

Why is the GlobalHost a public property here? I always keep the host private, in order to guard it from outside access. You should not need it anywhere else in your code, because you use DI anyway, or am I missing details?

DesignData class is using it.

@mrmorrandir
Copy link

Ahhh thanks for the help, I totally overlooked that...

I don't like the dependency though, but I get it for this scenario.

@pjmagee
Copy link

pjmagee commented Sep 29, 2024

Ahhh thanks for the help, I totally overlooked that...

I don't like the dependency though, but I get it for this scenario.

Might be able to make it private and expose an alternative for the DesignTime and wrap it around some compiler labels so its 'removed' from what would be considered actual runtime code?

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

Successfully merging this pull request may close these issues.

Microsoft.Extensions.HostBuilder integration sample
5 participants