Refreshing property in ViewModel of Window with EventAggregator from another class

So.. I have some core-class. While it is loading some modules I am trying to send some notifications to status-window with EventAggregator.GetEvent().Publish(). Status window showing:

private Core()
        {
            SystemManager.EventAggregator.GetEvent<StartProgressWindow>().Publish(null);
            this.InitializeCore();
        } 

Where StartProgressWindow is starting status-window event and InitializeCore method is where all the modules are loading.

Status notifications sending:

Core.EventAggregator.GetEvent<ChangeProgressStatus>().Publish("Some module is loading");

And subscriber:

eventAggregator.GetEvent<ChangeProgressStatus>().Subscribe((message) =>
                {
                    this.Status = message;
                });

Status property:

public string Status 
        {
            get
            {
                return status;
            }
            set
            {
                this.status = value;
                RaisePropertyChanged("Status");
            }
        }

Binding:

<Label Content="{Binding Status, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>

And, actually, the problem:

Property changes with all the statuses that I'm sending it to. But it does not reflects on UI, it is forzen. I set the value of the Status-property to "Some string" in constructor of ViewModel's class and of course it reflects well. What I am doing wrong? Thanks, Pavel!

Answers


Have you tried making sure you're subscribing on the UI thread?

eventAggregator.GetEvent<ChangeProgressStatus>().Subscribe((message) =>
                {
                    this.Status = message;
                }, ThreadOption.UIThread);

I suspect it is because all your events are being handled at the same time as the InitializeCore() method is, so it doesn't actually render anything until all the events and the InitializeCore() method have finished

Try launching your StartProgressWindow event on a lower DispatcherPriority then Render, such as DispatcherPriority.Background

private Core()
{
    this.Dispatcher.BeginInvoke(DispatcherPriority.Background,
        new Action(delegate 
        { 
            SystemManager.EventAggregator.GetEvent<StartProgressWindow>().Publish(null);
        }));

    this.InitializeCore();
} 

Need Your Help

Get syscall.Handle from a Go *net.UDPConn on Windows?

windows sockets networking go multicast

How do I obtain the underlying syscall.Handle for a *net.UDPConn on Windows? I want this handle to set the IP_MULTICAST_TTL via syscall.SetsockoptInt. On Linux I do the following:

How can I xor a string character with an int in Python?

python encryption xor rc4-cipher

I'm trying to create a Python Ciphersaber 2 implementation since those that I've found on the net appear to produce gibberish. During the deciphering, I need to be able to xor a single character of a