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?

fractor
  • 1,534
  • 2
  • 15
  • 30
mihajlv
  • 2,275
  • 4
  • 36
  • 59
  • possible duplicate of [UIELement vs Frameworkelement in WPF/Silverlight](http://stackoverflow.com/questions/5956880/uielement-vs-frameworkelement-in-wpf-silverlight) – BoltClock Sep 05 '11 at 19:26
  • @mihajlv: The fact that the answer on that question may be wrong has nothing to do with whether it is a duplicate or not. – H.B. Sep 05 '11 at 19:35
  • @mihajlv: Also binding has nothing to do with the dispatcher... – H.B. Sep 05 '11 at 19:36

1 Answers1

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.

H.B.
  • 166,899
  • 29
  • 327
  • 400
  • 1
    so just to be clear UIElement provides none of the layout, data binding, styling, templates, and resources. – mihajlv Sep 05 '11 at 19:36
  • @H.B, how come UIElement have Measure and Arrange methods if it does not participate in layout? – wingerse May 27 '16 at 16:18
  • 1
    @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`. – H.B. May 27 '16 at 17:42