UIElement vs FrameworkElement
Asked Answered
K

1

7

I am unclear about when you would use a UIElement as opposed to a FrameworkElement, and why is there a FrameworkElement class at at all. Essentially, what is the extra functionality that a FrameworkElement provides as opposed to UIElement?

Krp answered 5/9, 2011 at 19:24 Comment(3)
possible duplicate of UIELement vs Frameworkelement in WPF/SilverlightEoin
@mihajlv: The fact that the answer on that question may be wrong has nothing to do with whether it is a duplicate or not.Laurent
@mihajlv: Also binding has nothing to do with the dispatcher...Laurent
L
5

You should never inherit from UIElement (no class besides FrameworkElement does), among other properties it has no DataContext, whose lack can land you in some troubles.

Laurent answered 5/9, 2011 at 19:29 Comment(3)
so just to be clear UIElement provides none of the layout, data binding, styling, templates, and resources.Krp
@H.B, how come UIElement have Measure and Arrange methods if it does not participate in layout?Epode
@EmperorAiman: The claim about it not participating in layout is presumably inaccurate, it seems to have some base capabilities but no concrete implementation and no way to adjust the size easily (as all those properties are missing). I don't know the reasoning between the separation of UIElement and FrameworkElement but just looking at what classes exist it stands to reason that one wants to use FrameworkElement.Laurent

© 2022 - 2024 — McMap. All rights reserved.