Skip to content

Attached properies don't work with UserControl (DependencyProperty.RegisterAttached) #3243

Closed

Description

@jeanplevesque

Current behavior

Attached properties don't work on UserControl like they work on Control.

Expected behavior

Attached properties work on UserControl like they work on any other Control.

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

  1. Create an attached property (using DependencyProperty.RegisterAttached).
  2. Create a UserControl.
  3. Use the attached property on the UserControl.
  4. Update the attached property via regular binding.
  5. Notice that the propertyChangedCallback isn't called.
    You'll also notice an System.InvalidCastException in BindableMetadata.g.cs if you have the exceptions attached.

Note that using the following workaround doesn't fix the bug:

<UnoSkipUserControlsInVisualTree>false</UnoSkipUserControlsInVisualTree>

Workaroud

Create a class (like "AttachableUserControl") that inherits from UserControl and use that everywhere you would use UserControl.

Environment

Nuget Package:

Package Version(s): 2.1.37

Affected platform(s):

  • iOS (yes, tested)
  • Android (yes, tested)
  • WebAssembly (not tested)
  • WebAssembly renderers for Xamarin.Forms
  • macOS (not tested)
  • Windows
  • Build tasks
  • Solution Templates

Visual Studio:

  • 2017 (version: )
  • 2019 (version: )
  • for Mac (version: )

Activity

  1. added
    kind/bug
    triage/untriaged
    on May 26, 2020
  2. changed the title [-]AttachedProperies don't work with UserControl[/-] [+]Attached properies don't work with UserControl (DependencyProperty.RegisterAttached)[/+] on May 26, 2020
  3. jeromelaban commented on Jun 1, 2020

    @jeromelaban
    Member

    I'm not able to reproduce this issue with neither 2.1.37 or the latest 3.0 dev bits. Here's the sample I used:
    UserControlTest2.zip.

    Can you validate that the repro is the one you wanted ?

  4. added and removed
    triage/untriaged
    on Jun 1, 2020
  5. jeromelaban commented on Jun 1, 2020

    @jeromelaban
    Member

    Scratch that. The property is not attached to the proper object, it's attached to the first element of the usercontrol, not the user control itself.

  6. added 5 commits that reference this issue on Jun 1, 2020
    559542c
    5c7e86a
    1a95506
    6359cf2
    8c1c42c
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/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions