Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Binding Source in 1.3

$
0
0

Before I had upgraded to 1.3, I was sad over the fact that the source for a binding was not customizable - i.e. it only bound to BindingContext.

I'm not sure why this wasn't mentioned in the 1.3 release (or if it was, I must have missed it) but there is now a Source property on Bindings that can be set in XAML and responds to markup extensions as expected.

It may not seem like a huge thing but it does open up a fair bit of extensibility to the binding system by letting you bind to other ui elements, static objects, etc...

In my specific case I'm setting the source to an object to pick up a global "IsBusy" indicator for whether to show a loading indicator that "persists" across page changes. Just one (important) step on the way to having a global busy indicator.

<ActivityIndicator IsRunning="{Binding IsBusy, Source={markup:ApplicationState}}" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1">
    <ActivityIndicator.Behaviors>
        <b:FadeToBehavior From="0" To="1" Trigger="{Binding IsBusy, Source={markup:ApplicationState}}" />
    </ActivityIndicator.Behaviors>
</ActivityIndicator>

The only quirk I've noticed is that Path needs to be set before Source. Not sure why that is but really who cares.

I think the grief that people have lately been voicing over XF is somewhat deserved (sorry to add on to that pile, just being honest) however I also think that alot of things have been done right and the move to 1.3 for me has largely been fantastic.


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>