Skip to content

ElementName binding on a UserControl does not work #3218

Closed

Description

@andrewD123

Current behavior

WASM Binding on a User control does not work but the same code on a page works fine.
Works on UWP.

Expected behavior

Binding to work like UWP.

How to reproduce it (as minimally and precisely as possible)

build a user control with binding. I used dependency property ienumerable
and bound to a combobox. I use the same code on a page vs user control and page works but user control does not.
I have a default page and I added the new page and new user control to the page and the page code works but not usercontrol

Create WASM project.
Create new page
Create new usercontrol
add binding code to both.
Add page to main page.
add usercontrol to main page.

Environment

Nuget Package:
latest build
Package Version(s):
latest build
Affected platform(s):

  • iOS
  • Android
  • [x ] WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

Activity

  1. added
    kind/bug
    triage/untriaged
    on May 22, 2020
  2. jeromelaban commented on May 26, 2020

    @jeromelaban
    Member

    Looks like this issue is related to #61. Could you apply the workaround specified there and let us know ?

  3. added and removed
    triage/untriaged
    on May 26, 2020
  4. andrewD123 commented on May 28, 2020

    @andrewD123
    Author

    UnoSkipUserControlsInVisualTree did not work.

  5. jeromelaban commented on May 28, 2020

    @jeromelaban
    Member

    Could you provide a full sample of your project ?

  6. andrewD123 commented on May 28, 2020

    @andrewD123
    Author
  7. jeromelaban commented on May 28, 2020

    @jeromelaban
    Member

    Thanks for the update. This looks like there's something specific with the binding engine.

    As a workaround, and better way to do so, you can write the following:

    <ComboBox x:Name="comboBox" Margin="90,58,0,0" d:LayoutOverrides="VerticalAlignment" Width="130" ItemsSource="{x:Bind MyProperty}"/>

    There's still an issue with ElementName binding for some reason, but you'll be able to get your binding working properly.

  8. added
    project/binding 🪢
    on May 28, 2020
  9. changed the title [-]User Control binding not working.[/-] [+]ElementName binding on a UserControl does not work[/+] on May 28, 2020
  10. andrewD123 commented on May 28, 2020

    @andrewD123
    Author

    other than chaning to x:bind did you do anything else? I still can't get it to work with this change.

  11. andrewD123 commented on May 28, 2020

    @andrewD123
    Author

    Looks like it does not work with a DP but it does work with ObservableCollection for a string but does not work for a class ObservableCollection

  12. andrewD123 commented on Jun 2, 2020

    @andrewD123
    Author

    Looks like if you use a class and binding by name the values still does not work.
    https://drive.google.com/file/d/1DVqTfE5Y2hw9M902Ps5MgkL7zy3wsOkg/view?usp=sharing

    Google Drive is a free way to keep your files backed up and easy to reach from any phone, tablet, or computer. Start with 15GB of Google storage – free.
  13. andrewD123 commented on Jun 2, 2020

    @andrewD123
    Author

    Also if it helps I have mainpage with a Frame control that has a page. In that page has a user control.
    x:bind does not work unlike the demo app I put on this ticket. I am not sure due the the layers of pages and controls this is causing an issue.
    demo app with Frame
    https://drive.google.com/file/d/1_9gE7FT-GKHhwgw_B0x02NenGi6ordxs/view?usp=sharing

  14. jeromelaban commented on Jun 2, 2020

    @jeromelaban
    Member

    A new build of the package has been published, can you revalidate ? x:Bind may still be needed.

  15. modified the milestone: 3.1 on Aug 28, 2020
  16. added
    project/animations 🎡
    and removed
    project/animations 🎡
    on Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugproject/binding 🪢

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions