question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] IsListNotNullOrEmptyConverter not working in android

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the “Reporting a bug” section on Contributing file?

Current Behavior

I have an observable collection and would like to enable / disable a button when the collection is empty or has items, but the button is always disabled. I have take a look to https://github.com/CommunityToolkit/Maui/blob/main/samples/CommunityToolkit.Maui.Sample/Pages/Converters/IsListNotNullOrEmptyConverterPage.xaml but I am not able to work with the converter

Expected Behavior

the button is disabled and when I add items to the list, the button is enabled

Steps To Reproduce

Run the attached project on Android. Press “Press to add items” and the “button disabled” should become enabled

Link to public reproduction project repository

https://github.com/acaliaro/MauiAppIsListNotNullOrEmptyConverterProblem

Environment

- .NET MAUI CommunityToolkit:5.0.0
- OS:Android 10
- .NET MAUI:7

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
acaliarocommented, Mar 6, 2023

OnPropertyChanged(nameof(Lista));

this works, thanks @bijington and @brminnick

1reaction
bijingtoncommented, Mar 4, 2023

Oh try this then

OnPropertyChanged(nameof(Lista));

To answer your question directed to @brminnick you don’t need to use [ObservableProperty] with ObservableCollection as it is a special type of collection that handles the raising of events. All other collection types like List will still require the use of the attribute.

I believe the importance of ObservableCollection is not that it implements INotifyPropertyChanged but actually INotifyCollectionChanged. This distinction helps to realise that it is firing events specific to a collection changing and therefore apply to using with controls that have an ItemsSource property.

This might give a little more detail:

https://learn.microsoft.com/en-us/dotnet/api/system.collections.objectmodel.observablecollection-1?redirectedfrom=MSDN&view=net-7.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug] ListIsNullOrEmptyConverter doesn't respect ...
a/converters This issue/PR is related to converters ; bug Something isn't working. Breaky break. ; s/unverified This issue needs verification/ ...
Read more >
IsListNotNullOrEmptyConverter - .NET MAUI Community ...
The IsListNotNullOrEmptyConverter is a one way converter that converts IEnumerable to a bool value.
Read more >
Issues with Android Studio Room Type Converter
For some reason, I am having issues with the typeconverter in Android Studios. I have tried a variety of solutions from other posts,...
Read more >
.NET MAUI: Android Bug - Map's MoveToRegion Method Not ...
The bug we are addressing pertains to the Map control in .NET MAUI applications on the Android platform. In some cases, the MoveToRegion...
Read more >
Why does MAUI have so many bugs? : r/dotnetMAUI
I'm not done with Maui. I'm not sure these are really bugs but I've seen differences in the UI between IOS and Android...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found