Bind to a single Realm object #3500
Unanswered
Jean-RobertLaffineur
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You should be able to use the updateRealm.All<MyObject>().Where(...).SubscribeForNotifications(callback);
void callback(IRealmCollection<BeatmapSetInfo> sender, ChangeSet? changes)
{
if (sender.Any())
{
// display item
}
else
{
// display placeholder
}
} The callback will fire once after the query completes (asynchronously) and then once more when the query changes. In your example you say it's one-or-none so you don't even need to check the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I need to bind a single Realm object to my UI (MAUI dotnet 8) to display its properties in my application. The documentation gives a clue at how this can be done:
This works fine for an object that exists for the whole UI lifecycle, but in my case, the object I need to bind to is the result of a query that sometimes gives one object and sometimes none. My UI should display the object when there is one, and some empty fields otherwise.
So far I have implemented it using an
IQueryable
property containing the result of the query:... and a binding value converter that converts the
IQueryable
to a single object:I feel like this is not the right way to do it, as I sometimes get invalid objects issues and object's PropertyChanged that suddenly stop being fired, but the documentation is very limited in terms of examples. Any idea?
Beta Was this translation helpful? Give feedback.
All reactions