Bug 60425 - XAML Composite Bindings don't work when linking Sdk and User Assemblies
Summary: XAML Composite Bindings don't work when linking Sdk and User Assemblies
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-28 14:47 UTC by francedot
Modified: 2017-10-30 19:28 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description francedot 2017-10-28 14:47:45 UTC
XAML Composite Bindings don't work when linking Sdk and User Assemblies.

I have the below scenario: a property of ViewModel inside a PageViewModel which I want to bind in XAML.
No problem on iOS, but on Android when enabling "linking Sdk and User Asseblies" Bindings are not set and I get this kind of console logs:
mono-stdout: Binding: 'SelectedBusiness.Name' property not found on 'Mercurio.PageViewModels.MapsPageViewModel', target property: 'Xamarin.Forms.Label.Text'.

The only way I found to workaround the issue is to manually set each of the control BindingContext via code.

<StackLayout Spacing="0"
             Margin="0,2,0,0">
             <Label TextColor="#5a5555"
                    x:Name="BusinessNameLabel"
                    FontSize="17"
                    Text="{Binding SelectedBusiness.Name}"/>
             <ScrollView Margin="0,6,0,0">
                    <StackLayout Spacing="0">
                          <Label x:Name="BusinessTagLabel"
                                 TextColor="#ee5252"
                                 FontSize="15"
                                 Text="{Binding SelectedBusiness.Tags[0].Value}"/>
                          <Label x:Name="BusinessAddressLabel"
                                 TextColor="#8e8e8e"
                                 FontSize="14"
                                 Margin="0,8,11,0"
                                 Text="{Binding SelectedBusiness.Address}"/>
                    </StackLayout>
             </ScrollView>
</StackLayout>
Comment 2 Stephane Delcroix 2017-10-30 19:23:07 UTC
That's expected behavior. if no code (but only xaml) references your VM property, the linker can link it away.

you can fix that by [Presrve]ing your type and attributes, enabling XamlC or not linking user assemblies.

if this does not solve the issue, please provide a reproduction project (and reopen the ticket)
Comment 3 Stephane Delcroix 2017-10-30 19:28:04 UTC
additional note: turning XamlC will only solve this if you compile the bindings too using x:DataType