I have a code where i want to update the UI when some progress is going on in ViewModel. I set the property value to "Please wait" through some DelegateCommand. Although the value gets updated for the property but view doesn't get updated. If I change the property value through some method in ViewModel it updates the UI.
is this a known issue or bug in Prism 6?
Platform:
code snippet
XAML: TextBlock Text="{Binding UpdateValue, Mode=TwoWay}"
in ViewModel
private string _updateValue;
public string UpdateValue
{
get
{
return this._updateValue;
}
set
{
this._updateValue = value;
this.OnPropertyChanged("UpdateValue");
}
}
Constructor:
ViewModel()
{
ConnectCommand = new DelegateCommand
...
}
private void ExecuteConnectionWindow(string obj)
{
_updateValue = "Please wait...";
...
}
But it doesn't change the UI property.
It should be
this.UpdateValue = "Please wait...";
I got the issue. I don't know if its a bug in prism 6 or it's the design of Prism.
However let me point out the core issue.
I thought in Prism 6.0 there is no difference between OnPropertyChanged() method and Setproperty()method except using SetProperty<T> You can reduce the set method to just one line also ref parameter allows you to update its value.
But there is a difference between OnPropertyChanged()method and Setproperty() method.
However there should not be as BindableBaseis an abstract class implements INotifyPropertyChanged().
public abstract class BindableBase : INotifyPropertyChanged
{...}
If I have a property "UpdateValue" in MainViewModel with SetProperty() method.
And I want to update the value through a "DelegateCommand". the value gets updated but it doesn't update the UI.
But for the same property value if I set "OnPropertyChanged()" then the value gets updated in the UI through "DelegateCommand".
Can anyone explain this behaviour.
There is no difference in behavior. Provide the code that does not work for you.
I have attached the code here. Sorry for the late reply as I have to create a new project and then share.
PrismDummyApp.zip
Thanks
@deb1bhu You should not set the value of the underlying field before calling SetProperty. SetProperty sees that the value did not changed and does nothing:
_updateValue1 = value; // <<<< remove that
SetProperty(ref _updateValue1, value);
Ohhh
Thanks for the help. It really works.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.