Sourabh Soni
What is difference between ContentControl and ContentPresenter?
By Sourabh Soni in .NET on Jul 20 2016
  • Sujeet Singh
    Jul, 2018 22

    ContentControl is a base class for controls that contain other elements and have a Content-property (for example, Button).ContentPresenter is used inside control templates to display content.ContentControl, when used directly (it's supposed to be used as a base class), has a control template that uses ContentPresenter to display it's content.My rules of thumb (not applicable in every case, use your judgment):Inside ControlTemplate use ContentPresenter Outside of ControlTemplate (including DataTemplate and outside templates) try not to use any of them, if you need to, you must prefer ContentPresenter Subclass ContentControl if you are creating a custom "lookless" control that host content and you can't get the same result by changing an existing control's template (that should be extremely rare).

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS