Skip to content

DataContext should only be available on FrameworkElement #13201

Closed

Description

@Youssef1313

Current behavior

It's generated by DependencyObjectGenerator for much more classes than needed.

Expected behavior

It should only be for FrameworkElement.

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

No response

Workaround

No response

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

No response

Affected platforms

No response

IDE

No response

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

Activity

  1. added
    kind/bug
    triage/untriaged
    difficulty/tbd
    on Aug 11, 2023
  2. jeromelaban commented on Aug 14, 2023

    @jeromelaban
    Member

    We can't change change one for Uno 5, it will be breaking too much.

  3. added
    difficulty/medium 🤔
    and removed
    triage/untriaged
    difficulty/tbd
    on Sep 20, 2023
  4. github-actions commented on Aug 11, 2025

    @github-actions
    Contributor

    Hey there — just a heads-up that this issue has been quiet for over a year. If there’s no update or comment in the next 10 days, it’ll be closed automatically. Feel free to remove the stale label or drop a note to keep it open.

  5. added
    stale
    on Aug 11, 2025
  6. removed
    stale
    on Aug 11, 2025
  7. MartinZikmund commented on Aug 11, 2025

    @MartinZikmund
    Member

    Still relevant

  8. MartinZikmund commented on Nov 8, 2026

    @MartinZikmund
    Member

    This is done: PR #23547 made DataContext, DataContextProperty and DataContextChanged public on FrameworkElement only, matching WinUI, and they are now declared in

    public object DataContext
    {
    get => GetValue(DataContextProperty);
    set => SetValue(DataContextProperty, value);
    }
    #nullable enable
    [UnconditionalSuppressMessage("Trimming", "IL2111")]
    public static DependencyProperty DataContextProperty { get; } =
    DependencyProperty.Register(
    name: nameof(DataContext),
    propertyType: typeof(object),
    ownerType: typeof(FrameworkElement),
    typeMetadata: new FrameworkPropertyMetadata(
    defaultValue: null,
    options: FrameworkPropertyMetadataOptions.Inherits,
    propertyChangedCallback: (s, e) => ((FrameworkElement)s).OnDataContextChanged(e)
    )
    );
    public event TypedEventHandler<FrameworkElement, DataContextChangedEventArgs>? DataContextChanged;
    . The change is on master and ships in 7.0. Please open a new issue if you still see DataContext exposed where it shouldn't be.

    This was checked as part of an AI-assisted backlog review by reading the code, not by running it. If it looks wrong, please reply and we will take another look.

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/medium 🤔kind/bugno-repro

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions