CommunityToolkit / CommunityToolkit/dotnet

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

Open
#1,166 2 comments 0 reactions 0 assignees View on GitHub
bug :bug: mvvm-toolkit :toolbox: needs author feedback :memo:
Dominant language
C#
Stars
3.8k
Forks
400
PR merge metrics
No merged PRs in 30d

Description

### 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

- Run the ObservablePropertyIssue sample attached in this https://github.com/SuthiYuvaraj/Samples/tree/main/ObservablePropertyIssue repository.
- Open the Picker and select an item.
- After selecting the item, the SelectionText is not updated. The PropertyChanged notification is never raised.

```csharp

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.