csla: Problem with how OnPropertyChanged fires for WinForms app vs Xamarin app

I’ve run into a problem with OnPropertyChanged. In WinForms, it appears OnPropertyChanged only fires for the property that is actually changing even though BusinessRules are run for any of the dependencies. In XAML, OnPropertyChanged fires for the dependencies as well. I do know this relates to the ApplicationContext.PropertyChangedMode property.

Because of this, I’m running into inconsistent behavior between our WinForms app and XAML app. Certain methods are getting called in OnPropertyChanged that we only expect to get called when that property value actually changes and not when it’s “Changed” as a dependency, like the attached image. I tried setting PropertyChangedMode to Windows for the XAML app, but certain validation isn’t being shown in the UI like it is when set to XAML

Do you have a suggestion on how to handle this?

image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (12 by maintainers)

Most upvoted comments

I don’t think there is an ideal solution to this discrepancy. You can change the Winforms configuration to behave like the WPF app and raise an event for every property that was changed. The downside to this is a potential performance issue because Winforms databinding reads every bound property when a single property changes.

We have chosen to live with the performance hit, which is not usually noticeable. When it is noticeable due to a property that is somewhat complex to evaluate, we add an internal field to store a “cached” result, often using a nullable value. On any property change that could affect the cached result, we clear the cached field and the first property get will calculate it, but subsequent property gets will just return the cached result.