Q:

Notify ViewModel on change in static Model

I'm designing a LogManager class to handle all my logs in my application, in the form of LogMessage objects. They are saved in an ObservableCollection in the class. The LogManager itself is static for access in every part of my program.
Now I want to make a View that can display the ObservableCollection of LogMessages, but I can't wrap my head around how I could notify the ViewModel that a new LogMessage has been added...
I tried implementing INotifyPropertyChanged, but since the class is static this is not possible.
PS: I'm using the MVVM-Light toolkit for my application

A:

You should consider the responsibilities of you LogManager. Does it really need to implement INotifyPropertyChanged?
You can use a StaticResource in your XAML for the LogManager or provide a property for it inside the View's ViewModel.
ViewModel:
//Placeholder class
public static class LogManager
{
    public static ObservableCollection<LogMessage> Messages { get; }
}

public class LogMessage
{
    public string Text { get; set; } 
}

public class LogManagerViewModel
{
    public ObservableCollection<LogMessage> Messages { get { return LogManager.Messages; } }
}

XAML:
<ListBox ItemsSource="{Binding Messages}" DisplayMemberPath="Text" />

That said I would find it advisable to consider using the builtin dependency injection capabilities of MvvmLight and making the LogManager non static.

