Skip to content

FrameworkElement.DataContextChanged has different signature from UWP #2870

Closed

Description

@MartinZikmund

Current behavior

DataContextChanged event has a different signature in Uno than in UWP. If it is not intentional, maybe it could be added to #2240 ?

UWP uses:

TypedEventHandler<FrameworkElement, DataContextChangedEventArgs>

While Uno has:

TypedEventHandler<DependencyObject, DataContextChangedEventArgs>

Is this difference intentional?

Expected behavior

The event handler is the same.

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

Attach a DataContextChanged event to page in UWP project head. Notice that other platforms now fail to compile until changed to DependencyObject.

Environment

Nuget Package: latest

Package Version(s): latest

Affected platform(s):

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

Activity

  1. added
    kind/bug
    triage/untriaged
    on Mar 23, 2020
  2. jeromelaban commented on Mar 23, 2020

    @jeromelaban
    Member

    Indeed, thanks Martin!

  3. added and removed
    triage/untriaged
    on Apr 4, 2020
  4. modified the milestone: 3.1 on Aug 29, 2020
  5. added
    project/binding 🪢
    on Sep 15, 2020
  6. added
    project/animations 🎡
    and removed
    project/animations 🎡
    on Sep 21, 2020
  7. ToddGlodek commented on Oct 1, 2020

    @ToddGlodek

    Workaround
    As suggested by @abrull

    I just realized that on Android and iOS in the even handler the sender is DependencyObject and on UWP the sender is FrameworkElement so I just created different event handlers for each platform

    I did it like this...
    `
    public DrawingSurface()
    {
    this.InitializeComponent();
    DataContextChanged += this.DrawingSurface_DataContextChanged;
    }

    #if WASM
    private void DrawingSurface_DataContextChanged(DependencyObject sender, DataContextChangedEventArgs args)
    #else
    private void DrawingSurface_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs args)

    #endif
    {
    }

  8. jeromelaban commented on Oct 2, 2020

    @jeromelaban
    Member

    Yes, thanks for the update. This is a breaking change that has not been integrated into Uno yet. We're generally batching those as part of larger set of breaking changes so it does not break dependents too often.

  9. MartinZikmund commented on Oct 25, 2020

    @MartinZikmund
    MemberAuthor

    Similar difference is for Loading event as well

  10. added
    difficulty/tbd
    on Feb 15, 2021
  11. added
    difficulty/starter 🚀
    and removed
    difficulty/tbd
    on Jun 1, 2021
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

    difficulty/starter 🚀kind/bugproject/binding 🪢

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions