Skip to content

[BUG] [ObservableProperty] OnChanged Callback Not Firing with TwoWay Binding #1166

@SuthiYuvaraj

Description

@SuthiYuvaraj

Describe the bug

When using [ObservableProperty] from CommunityToolkit.Mvvm 8.4 on a bool property bound TwoWay to Microsoft.Maui.Controls.Picker.IsOpen, the generated OnIsProjectPickerExpandedChanged method is never called

Regression

8.0.3

Steps to reproduce

<Picker Title="Select a project" 
        ItemsSource="{Binding Projects}" 
        ItemDisplayBinding="{Binding Name, x:DataType=models:Project}" 
        SelectedItem="{Binding SelectedProject}" 
        SelectedIndex="{Binding SelectedProjectIndex}" 
        IsOpen="{Binding IsProjectPickerExpanded, Mode=TwoWay}"/>

public partial class MainPageViewModel : ObservableObject
{
    [ObservableProperty]
    private bool _isProjectPickerExpanded;

    [ObservableProperty]
    private string _selectionText = "No project selected";

    partial void OnIsProjectPickerExpandedChanged(bool value)
    {
        SelectionText = value
            ? "Picker is open..."
            : SelectedProject is not null
                ? $"Selected: {SelectedProject.Name}{SelectedProject.Description}"
                : "No project selected";
    }

    // ...
}

With reference to the code snippet , OnIsProjectPickerExpandedChanged is never called.

Expected behavior

The OnIsProjectPickerExpandedChanged PropertyChanged method is expected to be invoked whenever the IsOpen property changes.

Screenshots

No response

IDE and version

VS 2022

IDE version

No response

Nuget packages

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

Nuget package version(s)

8.0.4

Additional context

  • .NET MAUI CommunityToolkit:8.0.4
  • OS: MacCatalyst Xcode 26.2
  • .NET MAUI:11.0.0-preview.1.26104.11

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛An unexpected issue that highlights incorrect behaviormvvm-toolkit 🧰Issues/PRs for the MVVM Toolkitneeds author feedback 📝This issue or PR needs a reply from the author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions