Skip to content

ObservableProperty failed in release modeΒ #1111

@rodolfo-sousa

Description

@rodolfo-sousa

Describe the bug

I start to have a problem with the last version of CommunityToolkit.Mvvm 8.4.0 (I tried 8.3.2 too), where it fails to change an Observable Property when using RelativeSource AncestorType on Release mode.

So, I have a user control that appears every time the MessageShow changed to True in ViewModel. After click on a button inside of the control, the same property is changed to False.
Every time I need to show the control a do the same.

It stop to work after I update Toolkit and SDKs.

Here is a sample, works in Debug but fails in Release mode:

        <controls:CPopUps   BindingContext="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:DebugViewModel}}}"
                                                      
                            MessageShow="{Binding PopUpMessageShow, Source={RelativeSource AncestorType={x:Type viewmodels:DebugViewModel}}, Mode=OneWay}" />

I tried to disable AOT and Trimmed but no luck.

So I found this approach and it worked:

        <controls:CPopUps   BindingContext="{Binding Source={RelativeSource AncestorType={x:Type viewmodels:DebugViewModel}}}"
                                                      
                            MessageShow="{Binding PopUpMessageShow, Mode=OneWay}" />

Don't know if a BUG or bad usage, but was working in the past...

Regression

SDK 9.0.202

Steps to reproduce

  1. Create a user control with Binding properties;
  2. Put it on a View;
  3. Change the property from ViewModel;
  4. Change the property in User Control;
  5. Property is not changed on ViewModel;

Expected behavior

Observable Property should be updated on ViewModel after it's changed in the user control.

Screenshots

No response

IDE and version

VS 2022

IDE version

17.14.9

Nuget packages

  • CommunityToolkit.Common
  • CommunityToolkit.Diagnostics
  • CommunityToolkit.HighPerformance
  • CommunityToolkit.Mvvm (aka MVVM Toolkit)

Nuget package version(s)

8.4.0

Additional context

No response

Help us help you

No, just wanted to report this

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug πŸ›An unexpected issue that highlights incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions