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

[WIP] AvaloniaUI support #738

Closed
wants to merge 6 commits into from
Closed

Conversation

megazyz
Copy link

@megazyz megazyz commented Jan 19, 2021

This makes Caliburn.Micro work with AvaloniaUI.
Related to #556.
Needs review and testing.

@KasperSK
Copy link
Member

This look interesting, I will try and a review it once I get an hour or two of free time.

if (owner != null && isDialog)
{
//TODO: (Avalonia) Set window owner
//window.Owner = owner;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be commented out?

{
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
//TODO: (Avalonia) Set window owner
//window.Owner = owner;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to set window owner here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

judging from the methods name, it should.
why has nobody answered your review-questions for such a long time?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the question is because this flow is not valid for Avalonia.
You pass the owner as parameter to ShowDialog (mandatory) or Show (optional). So it is really a business/architectural decision if we divert from traditional Caliburn way of doing it at the cost of introducing inconsistencies between platforms.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also beware that work has continued here: https://github.com/Caliburn-Micro/Caliburn.Micro/tree/556-compatibility-inquiry-avaloniaui
It can use a rebase btw cause it is not compatible anymore with current master, there are conflicts due to merge of MAUI support.

@vb2ae
Copy link
Member

vb2ae commented Apr 17, 2021

Could you add a sample AvaloniaUI app to the samples also?

@megazyz
Copy link
Author

megazyz commented May 16, 2021

Could you add a sample AvaloniaUI app to the samples also?

Done.

I'm not sure where it would be ideal to start the CM bootstrapper. Now it's created in App.OnFrameworkInitializationCompleted() in App.axaml.cs. Another solution might be to include it as a resource in App.axaml like in WPF.

@KasperSK KasperSK marked this pull request as ready for review June 7, 2021 13:43
@KasperSK KasperSK marked this pull request as draft June 7, 2021 13:44
@KasperSK
Copy link
Member

Should we namespace this similarly to the Xamarin.Forms package? I don’t think we can determine whether or not a project uses Avalonia otherwise.

@vb2ae
Copy link
Member

vb2ae commented Jul 29, 2021

I agree we need an Avalonia package similar to the xamarin.forms

@KasperSK
Copy link
Member

Also I think this was made before we reintroduced the Xamarin.Forms package so the branch needs to be rebased and the Caliburn.Micro.Platform.Core should be referenced as it is for the Xamarin.Forms package and the regular Caliburn.Micro package.

@Stannieman
Copy link

Stannieman commented Apr 26, 2022

What are the steps left to have this into Caliburn? It looks like it works but we need some restructuring? I could help some but am not sure where in the process we are atm.

@vb2ae
Copy link
Member

vb2ae commented Apr 27, 2022

will work on fixing merge conflicts and see if we can get it merged in this weekend. It will need testing

@KasperSK
Copy link
Member

I tried a while back to include Avalonia in the features sample project, and ran into some issues with the way navigation was handled via frame adapter. I think if we can make it work with the features sample project it will be a good test.

@Stannieman
Copy link

Stannieman commented Jul 15, 2022

I rebased this PR on the latest Caliburn master and was planning to move this forward a bit, but ran into some issues.
It happens to be that the project I was using it in did not actually use Caliburn for navigation (I called ViewLocator and ViewModelBinder manually).
Today I tried to use Conductor.ActivateItemAsync like you should. However I found that it does not try to find a view.
Am I missing something here or is this the navigation problem @KasperSK is talking about?
There is nothing wrong with naming conventions, it does not call the ViewLocator at all.

It was my fault. Ignore it.

@vb2ae
Copy link
Member

vb2ae commented Jul 16, 2022

Created a branch of my own to keep working on this. https://github.com/Caliburn-Micro/Caliburn.Micro/tree/556-compatibility-inquiry-avaloniaui The biggest issue I have remaining is getting

      cal:Message.Attach="RegisterFrame($source)" 

events to fire.

@Stannieman
Copy link

Stannieman commented Jul 16, 2022

Created a branch of my own to keep working on this. https://github.com/Caliburn-Micro/Caliburn.Micro/tree/556-compatibility-inquiry-avaloniaui The biggest issue I have remaining is getting

      cal:Message.Attach="RegisterFrame($source)" 

events to fire.

I have a fix/improvement, shall I make a pull request to your branch or how will we coordinate this?
Made a PR.

@danwalmsley
Copy link

@megazyz and all! I am from Avalonia! I would like to help resurrect this PR.

@megazyz how complete is this?

@danwalmsley
Copy link

@megazyz and all! I am from Avalonia! I would like to help resurrect this PR.

@megazyz how complete is this?

@vb2ae I have seen your branch, testing it out! Would love to help get it finished. Let me know of how I can assist. For now I shall test it out find my way around!

@Stannieman
Copy link

Stannieman commented Mar 16, 2023

The latest Avalonia nightlies have some breaking changes. Luckily they are focussing on bug fixes for the upcoming version from now on so I don't expect more breaking stuff to be added.

One has to do with different parameters in InitializeComponent which is called through reflection by Caliburn. I have a fix for this locally that I'll create a PR for.
One other issue has to do with registering event triggers, not sure exactly what is the cause there.

Then we need to also rebase this branch on master because I am sure there are some conflicts. Some other thing might still be missing that I don't encounter in my project, @vb2ae has more details about them I think.

@megazyz
Copy link
Author

megazyz commented Mar 17, 2023

I apologize for my absence. Thank you for looking into this and continuing the development.

@Stannieman
Copy link

@megazyz you do this in your free time so no apologies needed mate

@vb2ae vb2ae closed this May 7, 2023
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.

6 participants