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

In XAML, how do you bind a property element (not a property attribute)?

$
0
0

The typical way to do bindings in XAML is using property attributes, and this works just fine:

<Label Text="{Binding CategoryName}" />

One should also be able to bindings on property elements, but this doesn't work:

<Label>
    <Label.Text>
        <Binding Path="CategoryName" />
    </Label.Text>
</Label>

That approach fails with a TargetInvocationException upon creating the page.

Note that other Markup Extensions on a property element work fine, such as x:Static:

<Label>
    <Label.Text>
        <x:Static Member="local:GlobalResources.CategoryString" />
    </Label.Text>
</Label>

...and custom markup extensions:

<Label>
    <Label.Text>
        <local:LocalizedTextExtension Key="page_main_button_settings" />
    </Label.Text>
</Label>

Both of those work without problem. Can someone advise on how to make this work for Binding too, assuming it can be done?


Viewing all articles
Browse latest Browse all 58056

Trending Articles



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