Xamarin.forms: XAML Binding x:Reference searches in wrong scope

Created on 18 Sep 2018  路  7Comments  路  Source: xamarin/Xamarin.Forms

Description

The Source of a Binding searches in the wrong scope for an element with the x:Name when x:Reference is used. (XAML)
Possible cause: https://github.com/xamarin/Xamarin.Forms/pull/2556

Steps to Reproduce

  1. Create a custom view that defines the x:Name of it's root element as "root", and give it a bindable property.
  2. Implement the custom view in a view/page which also has its root element x:Name set to "root".
  3. Bind the bindable property of the custom view to a property on the view/page (which implements the custom view).

Expected Behavior

The value of the property on the custom view is filled with the value of the bindable property on the view/page that implements the custom view.

Actual Behavior

The binding searches for the bindable property on the custom view, instead of the view/page that implements the custom view. So no value is set.

Basic Information

  • Version with issue: Xamarin.Forms 3.2.0.839982
  • Last known good version: Xamarin.Forms 3.1.0.697729
  • IDE: Visual Studio for Mac 7.6.5
  • Platform Target Frameworks:

    • iOS: 8.0

    • Android: 8.1

  • Android Support Library Version: 27.0.2.1
  • Nuget Packages: Xamarin.Forms
  • Affected Devices: All

Reproduction Link


Test project which has the new Xamarin.Forms version (3.2.0.839982).
ReferenceTest.zip
Simply replace it with 3.1.0.697729 and it works.

Xaml </> 5 regression bug

Most helpful comment

I can confirm this...just upgraded to 3.2 from 3.1...bindings fail when x:Name is the same for embedded custom views; workaround seems to be set a unique x:Name for each XAML custom view.

All 7 comments

I can confirm this...just upgraded to 3.2 from 3.1...bindings fail when x:Name is the same for embedded custom views; workaround seems to be set a unique x:Name for each XAML custom view.

I have same issue after upgrading. Looking forward to this getting fixed :)

@jvoostv1 the attached project has root and root2, but I get the idea

Hi! I still have this issue with Xamarin.Forms version 3.4.0.1009999. Downgrading to 3.1.0.697729 makes everything ok. Looking forward to the fix! :)

Hi! I still have this issue with Xamarin.Forms version 3.4.0.1009999. Downgrading to 3.1.0.697729 makes everything ok. Looking forward to the fix! :)

I've the same issue and done the same thing.

@PRopia99 @Vencode please open a new issue with a project attached. make sure you refer to this item as you do so

thanks

@StephaneDelcroix We already had the issue opened since November. https://github.com/xamarin/Xamarin.Forms/issues/4010#issuecomment-443125609

Was this page helpful?
0 / 5 - 0 ratings