You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
This is the first time I am using MvvmLight, so I hope I am not overlooking something obvious.
In my WPF ViewModel I have something like:
private ICommand readFileCommand;
public ICommand ReadFileCommand => readFileCommand ?? (readFileCommand = new RelayCommand(ReadFile));
private void ReadFile()
{
FileMessage = "Message.";
}
private string fileMessage;
public string FileMessage
{
get { return fileMessage; }
set
{
//Set(ref fileMessage, value);
fileMessage = value;
RaisePropertyChanged();
}
}
I have a couple of problems with it.
Main problem is that setting a property like FileMessage from within a method like ReadFile() does not result in an update of the view until ReadFile is completed.
There is a difference between using RaisePropertyChanged() which succeeds at that moment, and using Set() which does nothing at all. Though the latter did work outside such a method.
The problem extends to other elements like a DataGrid on a DataView.
In wondered if the called methods should be asynchronous, but that does not seem logical. I have not tried that yet as that does not really fit into what I want to achieve.
So what is happening? Am I overlooking something? Is this a limitation of the framework? Or is this a bug?
Thanks!
The text was updated successfully, but these errors were encountered:
May not be the issue but a couple of observations. Set will only call RaisePropertyChanged if the property value changes (check the bool response). If you want it raised every time use RaisePropertyChanged. The event may not be being raised until after the read file action if you are not yielding a thread. You would need to ensure your operation is not conducted on the UI thread to free that thread to update the UI. The read operation should be async or background worker or similar.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This is the first time I am using MvvmLight, so I hope I am not overlooking something obvious.
In my WPF ViewModel I have something like:
I have a couple of problems with it.
In wondered if the called methods should be asynchronous, but that does not seem logical. I have not tried that yet as that does not really fit into what I want to achieve.
So what is happening? Am I overlooking something? Is this a limitation of the framework? Or is this a bug?
Thanks!
The text was updated successfully, but these errors were encountered: