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

How to bind command to loaded event? #1049

Closed
MonkAlex opened this issue Jul 9, 2017 · 9 comments
Closed

How to bind command to loaded event? #1049

MonkAlex opened this issue Jul 9, 2017 · 9 comments
Labels

Comments

@MonkAlex
Copy link
Contributor

MonkAlex commented Jul 9, 2017

Has Avalonia any api similar with this?

@wieslawsoltes
Copy link
Contributor

Yes. https://github.com/wieslawsoltes/AvaloniaBehaviors

@Slesa
Copy link

Slesa commented Nov 18, 2018

Is there a way to find the possible events? Loaded seems not to exist, but the Click-Example works.

@vflame
Copy link

vflame commented May 7, 2019

Events:

http://avaloniaui.net/api/Avalonia.Controls/Window/

You can try the Opened or Initialized events. Both work.

@M0rdecay
Copy link

M0rdecay commented Oct 19, 2019

At what point does the Initialized event fire? Maybe I'm doing something wrong, the method attached to this event is never executed.

@Casper-SC
Copy link

Casper-SC commented Apr 11, 2020

At what point does the Initialized event fire? Maybe I'm doing something wrong, the method attached to this event is never executed.

Avalonia 0.9.7


   public class MainWindow : Window
    {
        public MainWindow()
        {
            Initialized += OnInitialized;

            InitializeComponent();
#if DEBUG
            this.AttachDevTools();
#endif
        }

        private void OnInitialized(object sender, System.EventArgs e)
        {
        }

        private void InitializeComponent()
        {
            AvaloniaXamlLoader.Load(this);
        }
    }

@M0rdecay
Copy link

M0rdecay commented Jun 10, 2020

Oh, it`s finally worked with Opened! Thanks!

@maxkatz6
Copy link
Member

AttachedToVisualTree event is equivalent or WPF Loaded event

@AstralisSomnium
Copy link

For me also only Opened worked.
AttachedToVisualTree and Initialized didn't work.

I hooked up after InitializeComponent();.

Any recommendations?

@maxkatz6
Copy link
Member

@AstralisSomnium What do you mean by "didn't work"? Event wasn't called?
AttachedToVisualTree is always called for controls that attached to visual tree, but for window it Is never called if I remember, because it doesn't attach to any visual or logical tree of elements.
For windows you need to use Opened.

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

No branches or pull requests

9 participants