Retrieving binding information!

FernandoVMFernandoVM BRMember ✭✭
edited August 2015 in Xamarin.Forms

Can I retrieve binding information from a given element? If one have in xaml

< Entry x:Name="entry1" Text="{Binding MyInfo}" / >

I would like retrieve (programatically) that the element 'entry1' is binded to 'MyInfo' property of BindingContext object. Is it possible?

Posts

  • adamkempadamkemp USInsider, Developer Group Leader mod

    No, that's not supported.

  • stvansolanostvansolano UMInsider, University ✭✭✭

    hey @fernandoVM what are you trying to do with that information?

    Saludos

  • FernandoVMFernandoVM BRMember ✭✭

    Hello @stvansolano, I would like attach a Behavior that reads more details (metadata) about my bindingcontext object.

  • stvansolanostvansolano UMInsider, University ✭✭✭

    @FernandoVM You could implement the attached behavior and you will get the underlying control (entry1) and by casting the object you will have the BindingContext, which contains MyInfo. Let me know!

    Saludos

  • FernandoVMFernandoVM BRMember ✭✭

    No @stvansolano, this does not solves the problem, the metadata is in MyInfo property, thus, I need know which property from BindingContext object is "binded" to Entry control.

  • stvansolanostvansolano UMInsider, University ✭✭✭

    Got you. Yeah I think it is not supported but hopefully we will get a GetBinding method or similar for XF someday :) Any lucky with Reflection maybe @FernandoVM?

  • FernandoVMFernandoVM BRMember ✭✭

    Hi @stvansolano, I already had inspected (runtime) the Entry control but I did can't found nothing to invoke with reflection, but I will continue trying, thanks by you attention! :smile:

  • adamkempadamkemp USInsider, Developer Group Leader mod

    If you want to hack around then look at the BindableObject.properties private field, which is a list of BindableObject.BindablePropertyContext objects. That is a private class with information about the bindings. You can find this stuff by using the Xamarin Studio assembly browser or any other .Net decompiler.

    Obviously this is not meant to be used outside of Xamarin.Forms core implementation so use at your own risk. I won't help you if it blows up in your face. ;)

Sign In or Register to comment.