C
C#2y ago
Elio

❔ OnpropertyChanged WPF

Hi everyone, i have _stepStore_PropertyChanged which is subscribe to _stepStore.PropertyChanged and i do not understand why my method is trigger twice ? if i put a breakpoint on the on both side one on the propertychanged in _stepStore and the other one in the method it not match like there is only one trigger inside _stepstore against 2 for the method.
3 Replies
Klarth
Klarth2y ago
Looks like a bit of a mess. It's unusual (IMO) for a VM to subscribe to PropertyChanged, though not unheard of. I would try ruling out subscribing to the event twice, somehow, as that's the most likely culprit. Besides that, use the call stack when inside _stepStore_PropertyChanged to see exactly where each call is coming from.
Elio
ElioOP2y ago
if i do not subscribe to _stepStore.propertychanged how i'm am supposed to trigger the propertyChanged() in ListingStepViewModel when _steps change ?
public class ListingStepViewModel : ViewModelBase
{
private readonly StepStore _stepStore;
public IEnumerable<StepViewModel>? Steps => _stepStore.Steps;

public StepViewModel? CurrentStep
{
get
{
return _stepStore.CurrentStep;
}
set
{
_stepStore.CurrentStep = value;
OnPropertyChanged();
}
}
.
.
.
public class ListingStepViewModel : ViewModelBase
{
private readonly StepStore _stepStore;
public IEnumerable<StepViewModel>? Steps => _stepStore.Steps;

public StepViewModel? CurrentStep
{
get
{
return _stepStore.CurrentStep;
}
set
{
_stepStore.CurrentStep = value;
OnPropertyChanged();
}
}
.
.
.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server