Realm .Net with WPF Binding


#1

I am trying to use Realm with a WPF application and pretty much everything is working fine except I have not figured out how to handle data binding to the Realm objects from a WPF XAML document so that two way updates are done within a Write() transaction. Currently I am creating a transaction when the form loads but the database update only occurs when the form is closed and I want to trigger a commit when each field (property) gets changed. Is there some straightforward way of achieving this - perhaps like the Swift method of overriding the setter to wrap the field level update in a write transaction? I guess I could create similar additional properties for the Realm objects to achieve the same thing except I would have to do it or every property on the object.


#2

There’s no super straightforward way to do that. We support it for Xamarin.Forms projects and support for WPF is on the roadmap, but we haven’t gotten around to implement it. I guess the easiest way to workaround this would be to create a Fody weaver that would generate the duplicate properties with the transaction opening logic.

Feel free to upvote the Github issue as we use those as a general guidance on customer interest.


#3

OK, thanks - not familiar with Fody but for now I’ll just create wrappers.